The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I have an SSAS tabular model based on Inventory data. The data contains not only the current (i.e. todays) On Hand values, but also 90 days worth of history. Here is a very small sample of data:
I need to create a DAX measure that will return that MAX Qty on Hand for each Material over the 90 days worth of history. In the sample above, the MAX would be 6, because on 2-Dec there was 3 in Loc A and 3 in Loc b.
I have tried the following DAX calculation:
CALCULATE (MAX(Inventory[SAP Qty On Hand]), ALL('Date'))
However, this is returning 3, rather than 6. It needs to aggregate by date before doing the MAX.
Any ideas?
Solved! Go to Solution.
Hi @cmncp, the following measure should do the job:
Max Daily Qty Over 90 Days := VAR currentDate = MAX( table[Dte] ) VAR beginDate = currentDate - 90 RETURN MAXX( CALCULATETABLE( VALUES(table[Date]) , ALLEXCEPT( table[Material] ) , table[Date] >= beginDate ) , CALCULATE( SUM(table[Qty On Hand]) ) )
Hi @cmncp, the following measure should do the job:
Max Daily Qty Over 90 Days := VAR currentDate = MAX( table[Dte] ) VAR beginDate = currentDate - 90 RETURN MAXX( CALCULATETABLE( VALUES(table[Date]) , ALLEXCEPT( table[Material] ) , table[Date] >= beginDate ) , CALCULATE( SUM(table[Qty On Hand]) ) )
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
99 | |
93 | |
82 | |
64 | |
58 |
User | Count |
---|---|
248 | |
123 | |
112 | |
79 | |
78 |