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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
gabrielp-sdmf
Frequent Visitor

How to ignore a external filter on a measure and add others inside

I'm trying to develop a measure to compare the average price of products in differente months.

In my calendar table, I have a column "MonthsFromMax" wich determine how many months from the current each month is (actual month is 0, last month is 1, and so on...)
So I made this DAX:


avg_price_vs_m0 = 
VAR
_price_act = CALCULATE([avg_price], calendario[MonthsFromMax] = 0, ALL(calendario))
VAR _price_ant = CALCULATE([avg_price], calendario[MonthsFromMax] = SELECTEDVALUE(calendario[MonthsFromMax])
RETURN
DIVIDE(_price_act - _price_ant, _price_ant)

I'm using it in a card to display the value, and set the filter to MonthsFromMax = 1 to make the comparison (also there are other cards with differente comparisons, MonthsFromMax = 3, MonthsFromMax = 6, and so on...)
But the ALL(calendario) in the _price_act returns a value ignoring all filters and brings the value for all time, and not the last month like I wish.
I've tried different approaches, but it always bring me the all time value, or BLANK, 'cause the filter conflict (like in this example, the external filter is MonthsFromMax = 1 and in the DAX MonthsFromMax = 0)
 
In short, I want the dax to ignore the external filter from MonthsFromMax, and use the provided on in the DAX instead.
 
Thank you so much for your help!
1 ACCEPTED SOLUTION
gabrielp-sdmf
Frequent Visitor

Actually I've figured out a way to do this.

Changed the MonthsFromMax filter to 0 and 1, and changed the DAX to:

 

avg_price_vs_m0 = 
VAR
 _price_act = CALCULATE([avg_price]calendario[MonthsFromMax] = 0)
VAR _price_ant = CALCULATE([avg_price], calendario[MonthsFromMax] = MAX(calendario[MonthsFromMax])
RETURN
DIVIDE(_price_act - _price_ant, _price_ant)
 
It worked just as I wanted to

View solution in original post

1 REPLY 1
gabrielp-sdmf
Frequent Visitor

Actually I've figured out a way to do this.

Changed the MonthsFromMax filter to 0 and 1, and changed the DAX to:

 

avg_price_vs_m0 = 
VAR
 _price_act = CALCULATE([avg_price]calendario[MonthsFromMax] = 0)
VAR _price_ant = CALCULATE([avg_price], calendario[MonthsFromMax] = MAX(calendario[MonthsFromMax])
RETURN
DIVIDE(_price_act - _price_ant, _price_ant)
 
It worked just as I wanted to

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors