Forum Discussion
Anonymous
6 years agoNot applicable
Current Inventory Levels
I need to figure out a measure that calculates the current inventory level based on items last inventory entry into the table. Below is an example of 5 items and to the right I flagged the last inve...
- 6 years ago
Bingo Anonymous , that's great. Did the trick. Definitely some syntax errors and I missed an EARLIER. PBIX is attached.
VAR __Table = ADDCOLUMNS( GROUPBY( 'Table', [Item], "__LastDate",MAXX(CURRENTGROUP(),[Date]) ), "__LastInventory",MAXX(FILTER('Table','Table'[Date] = [__LastDate] && 'Table'[Item] = EARLIER([Item])),'Table'[Qty]) ) RETURN SUMX(__Table,[__LastInventory]) - 6 years ago
Greg_Deckler
6 years agoCommunity Champion
Bingo Anonymous , that's great. Did the trick. Definitely some syntax errors and I missed an EARLIER. PBIX is attached.
VAR __Table =
ADDCOLUMNS(
GROUPBY(
'Table',
[Item],
"__LastDate",MAXX(CURRENTGROUP(),[Date])
),
"__LastInventory",MAXX(FILTER('Table','Table'[Date] = [__LastDate] && 'Table'[Item] = EARLIER([Item])),'Table'[Qty])
)
RETURN
SUMX(__Table,[__LastInventory])
Anonymous
6 years agoNot applicable
Hi GR ,
Thanks for your solution. One additional question: how do you need to modify the syntax if your dataset has the mutation for each item: in other words, in ReynoldTstan's example, for item 4 you want to show the cumulative number (0+4+3=7) instead of the last one (3)?
Thanks a lot for your help in advance!