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.
Hi guys,
The idea I want to achieve is pretty simple: I want to show the total Stock (based on a SUM of a column of table 'FACT Inventory') of the current month (2021-07), while it ignores any period selected from the 'DIM Calendar's period selection, which is related 1:* one directional to 'FACT Inventory'.
I thought about doing this the following way:
- First remove the entire 'DIM Calendar' filter context, by using ALL('DIM Calendar')
- Then after that, set it dynamically to the latest month, using the following DAX:
CALCULATE(
[Closing Stock],
ALL('DIM Calendar'[Date]),
FILTER(
'Fact Inventory',
RELATED('DIM Calendar'[YearMonth]) = FORMAT(TODAY(), "YYYY-MM")
)
)
The Closing Stock measure is really simple:
CALCULATE(
SUM('Fact Inventory'[Quantity]),
'Fact Inventory'[Source] = "OpeningStock"
)
Somehow this still reacts to a period that I select. If I select the entire 2021, I do see only a value at month 2021-07. However, If I select a period from 2021-01 until 2021-06, it won't show me the current month that is 2021-07.
Any ideas how to adapt the filter context in a way that it will show me the current month's value?
Kind regards,
Igor
Solved! Go to Solution.
Hello, you should probably use something like :
VAR _Today = FORMAT(TODAY(), "YYYY-MM")
RETURN
CALCULATE(
[Closing Stock],
ALL('DIM Calendar'[Date]),
'DIM Calendar'[YearMonth] = _Today
)
Works perfectly, thanks!
Hello, you should probably use something like :
VAR _Today = FORMAT(TODAY(), "YYYY-MM")
RETURN
CALCULATE(
[Closing Stock],
ALL('DIM Calendar'[Date]),
'DIM Calendar'[YearMonth] = _Today
)
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |