Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have a measure which I want to return the amount we have available in stock of a product.
Since we have a history per product per day, I'd want it to return the amount for the last day or whichever period we're dealing with (for example, 31/12/2020 if I have filtered on the year 2020, or today if I have no filter on the date, etc), but so far, it only works if I filter the date.
The measure goes :
Latest Amount := CALCULATE (
[_Quantity_Sum];
FILTER (
Fact_Stock;
Fact_Stock[Date of Stock]
= MAX ( 'Calendar'[Day in year] )
)
)
And like I said, it gives no result if I only select the product column and this measure, but it will give me a result if I filter on the month or on the day. Any idea on how to make it work with no filter ?
Kindly,
Nossair
@Anonymous , That need a row context to get it. Try this , but it will only give data for max date selected
Latest Amount :=
var _max = maxx(allselected('Calendar'),'Calendar'[Day in year])
return
CALCULATE (
[_Quantity_Sum];
FILTER (
Fact_Stock;
Fact_Stock[Date of Stock]
= _max
)
)
Hi @amitchandak ,
Thanks for your answer, however, indeed, it still doesn't give a result for when I don't filter on the date. Do you have an idea on why that's the case ? I'm still rather new to DAX and I can't quite put my finger on it.
Kindly,
Nossair
User | Count |
---|---|
98 | |
90 | |
77 | |
71 | |
64 |
User | Count |
---|---|
114 | |
98 | |
96 | |
68 | |
67 |