Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.
Can you help me create an measure that is independent from the date dimension, although a date related filtered is required in the formula?
My dataset is in a weekly level. We would like to have a yearly average which could be seen as the sum of the stock divided by 52 weeks. I created this formula:
avg_52_weeks =
var weeks_sum = CALCULATE(
SUM('table 1'[inventory_stock_freiv_qty]),
FILTER(dim_date, dim_date[week_age]>=-52),
FILTER(dim_date, dim_date[week_age]<=-1)
)
RETURN DIVIDE(weeks_sum,52)
The problem is that the user can filter the report by using the date dimension (year or week). I want the value of my measure to be fix when he does that. I don't want the average yearly stock to change when the user filtered time.
Example: I want the user to see 7367 even if he filters only week 2024W10, for example.
I think somehow the ALL() function could be used, but I don't know how. Below there is a power bi dummy file.
Thank you so much for your help!
Solved! Go to Solution.
Try this measure. The function ALLSELECTED clears dim_date filter context from within the visual (e.g., matrix rows). I changed the week_iso_yyyyxww field in the visual to use dim_date instead of 'table 1'; use dimension fields in visuals whenever possible.
avg_52_weeks =
var weeks_sum = CALCULATE(
SUM('table 1'[inventory_stock_freiv_qty]),
ALLSELECTED(dim_date),
dim_date[week_age]>=-52,
dim_date[week_age]<=-1
)
RETURN DIVIDE(weeks_sum,52)
Proud to be a Super User!
@DataInsights I just saw that if I use ALL() instead of ALLSELECTED() it works. Thank you so much!!!
Try this measure. The function ALLSELECTED clears dim_date filter context from within the visual (e.g., matrix rows). I changed the week_iso_yyyyxww field in the visual to use dim_date instead of 'table 1'; use dimension fields in visuals whenever possible.
avg_52_weeks =
var weeks_sum = CALCULATE(
SUM('table 1'[inventory_stock_freiv_qty]),
ALLSELECTED(dim_date),
dim_date[week_age]>=-52,
dim_date[week_age]<=-1
)
RETURN DIVIDE(weeks_sum,52)
Proud to be a Super User!
@DataInsights thank you so much for your help!
In the table it works as I wanted. However, the user still could filter the year in the date dimension or the week, and the value would change. I don't want that. I want to fix the average for the date dimension in all visuals. Is it possible?
I only want the value to change if the user filter a specific product, but the date table should have no influence because the 52 weeks average is a fix value...
Thanks again 🙂
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
72 | |
71 | |
68 | |
42 | |
42 |
User | Count |
---|---|
46 | |
40 | |
28 | |
27 | |
26 |