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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need help with DAX

Hey Everyone,

 

I need your help.

I have a table with Recording details by month and I would like to see the difference based on slicer selection.

User has to select two Months in a slicer to compare the numbers.

Difference = Recordings (Later Month) - Recordings (Earlier month) 

Jess90_0-1663792610298.png

 

Table data looks like this:

Jess90_1-1663792845522.png

 

Is there a way to make the measure dynamic so it follows the slicer selection?

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous There is if you unpivot those month columns so that you have:

Month, Value

March, 1200

April, 1500

...

You could then do this:

Difference Measure = 
  VAR __Min = MIN('Table'[Month])
  VAR __Max = MAX('Table'[Month])
  VAR __Month1 = MAXX(FILTER('Table',[Month] = __Min),[Recordings])
  VAR __Month2 = MAXX(FILTER('Table',[Month] = __Max),[Recordings])
RETURN
  __Month2 - __Month1

In reality, you will want a MonthSort column for Sort By and probably have to use that for your max/min, etc.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Anonymous There is if you unpivot those month columns so that you have:

Month, Value

March, 1200

April, 1500

...

You could then do this:

Difference Measure = 
  VAR __Min = MIN('Table'[Month])
  VAR __Max = MAX('Table'[Month])
  VAR __Month1 = MAXX(FILTER('Table',[Month] = __Min),[Recordings])
  VAR __Month2 = MAXX(FILTER('Table',[Month] = __Max),[Recordings])
RETURN
  __Month2 - __Month1

In reality, you will want a MonthSort column for Sort By and probably have to use that for your max/min, etc.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler ,

 

Really appreciate your help, that is definately best solution.

But what if I change the data little bit as below:

 

Jess90_0-1663810993586.png

Can you pls help with this too @Greg_Deckler ? 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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