Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jessicarocha
Helper IV
Helper IV

How can I fix a measure, so it is doesn't change with time slicer?

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. 

example_pb.jpg

 

Dummy PB file 

 

Thank you so much for your help!

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@jessicarocha,

 

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)

 

DataInsights_0-1724261601653.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
jessicarocha
Helper IV
Helper IV

@DataInsights I just saw that if I use ALL() instead of ALLSELECTED() it works. Thank you so much!!!

DataInsights
Super User
Super User

@jessicarocha,

 

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)

 

DataInsights_0-1724261601653.png

 





Did I answer your question? Mark my post as a solution!

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?

jessicarocha_0-1724311490552.png


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 🙂

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.