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.
Hello,
I have a Fact table like this:
Product | Customer | Region | Date | Sales |
In the middle of a calculation, I would like to put that table in a variable with the following filter:
Based on context | Based on context | Based on context | Any date | Based on context |
Product | Customer | Region | Date | Sales |
ALL seems to be the right function but I only manage to use it in a calculation with formula like this:
CALCULATE(
SUM(Fact[Sales] ,
All(Fact[Date]))
How could I use it to return the table above?
Thanks for your help!
Solved! Go to Solution.
I'm a bit worried about why you might want to do this as it could lead to performance issues and there might be alternative faster approaches. But to answer your question you could use the CALCULATETABLE function to create a table variable with an altered filter context.
eg.
VAR _factAllDates = CALCULATETABLE( Fact, ALL( Fact[Date] ) )
I'm a bit worried about why you might want to do this as it could lead to performance issues and there might be alternative faster approaches. But to answer your question you could use the CALCULATETABLE function to create a table variable with an altered filter context.
eg.
VAR _factAllDates = CALCULATETABLE( Fact, ALL( Fact[Date] ) )
Thanks a lot!
Yes, I have some tricky calculation to do and I could not find anyother solution than this... Ultimately, the goal is to design something similar to this:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656
Julien
@julien-rivley wrote:Thanks a lot!
Yes, I have some tricky calculation to do and I could not find anyother solution than this... Ultimately, the goal is to design something similar to this:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656
Julien
That's fine and the CALCULATETABLE approach should work, but you might find your performance is better doing some sort of ALL() over your date dimension rather than a CALCULATETABLE over your fact.
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 |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |