Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
82 | |
74 | |
66 |
User | Count |
---|---|
126 | |
105 | |
103 | |
81 | |
72 |