question

Sofia G21 avatar image
0 Likes"
Sofia G21 asked Jason Lightfoot commented

Can you use Global Macros to reference the name of a row instead of the row #?

I am trying to pull data from a table using a Global Macro. However, I want to label each of my rows with a SKU #. Can I make the Global Macro the SKU #? Or do Global Macros only work with Row #s?

FlexSim 22.2.0
global macro
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

Hi @Sofia G21, was our answer helpful? If so, please click the "Accept" button at the bottom of an answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Sofia G21 commented

Macros just replace their occurrence throughout your code with the text you defined, so if the expression evaluates correctly in a script you can use it as your macro definition.

Table("GlobalTable1")["Row1"]["Col1"]    

is a valid expression for a macro that uses the names of rows and columns.

If this isn't what you meant, then please include an example of what you were wanting to try.

Update: re-reading the question it sounds like you want to have in your code:

Table("GlobalTable")[SKU1]["Col1"]

where SKU1 is defined as

#define SKU1 "Row1"

which will work.

Update2:

I think I've finally latched onto what you want which is to have "09343558" as the row name. In the past we tried to avoid having number values for row headers and so I added ":" at the beginning so that they forced evaluation as a string in paths so ":09343558" - which of course can also have a macro definition.

My concern would be that if you have thousands of SKUs do you really want to create macros for them all? It suggests you're semi-hard coding your logic ('semi' since you can change the macro definitions) which might not be the best approach.


· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Sofia G21 avatar image Sofia G21 commented ·

screenshot-2023-03-20-150040.pngHey Jason, thanks for the various solutions you've provided. Here is what I'm trying to do:

I have a global table. The first column has the number of all of the SKUs (there's only 100). Instead of creating a global macro for the row number (which is difficult to track), I'd rather just call up the row with a Global Macro for its name which is the SKU #. From your notes, I assume this is how you're suggesting I build it? Is this correct?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Sofia G21 commented ·

Sorry I don't like the idea of putting data in the global macros are - usually they're deployed for speed and when you may need to change the format of a table in one place rather than throughout your code (e.g the number of fields and their order). In this case it sounds like it will be more work and not priovide you with the fastest table access.

Can you tell us more about your use case since I now see from your screenshot that ConvertingAsset to SKU is not a one to one relationship. Which value will you know and which value(s). will you want to look up? Will you know single values or a pair of them?

For fast access you can use bundle tables with an index or you can create map of the rows to lookup, but I'd like to give you an example that will work for your case rather than have a number of rounds of suggestions followed by more refined examples of your requirements.



1 Like 1 ·
Sofia G21 avatar image Sofia G21 Jason Lightfoot ♦ commented ·

Hey Jason, to reference the screenshot, the Row Name is 1 to 1 to the SKU column. (It doesn't really matter if Converting Asset or SKU is the first column for my use; I could really delete the SKU column if need be). Here's what I'm trying to do:

- I have 25 sources that depending on the SKU they run, they will have a different Inter-Arrival time. Each source can run 3+ SKUs, but only one SKU at a time.

- Every time I run the simulation, I want to say which 25 SKUs will be run. I was hoping of doing this using Global Macros, where I could type which SKU runs on which source ('Converting Asset') and it could pull it from the Global Table. This is where I thought it might be easier to have the Macro use the SKU to recall the row, instead of just recalling the row #.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.