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
kennym9
New Member

Calculating Variance based of Row Criteria

Hey Guys,

I'm trying to calculate the variance of units sold of a product based on period code, model, color, etc... Normaly I use the quick measure tool to handle this task but the way my table is setup, it wont allow me to.

This is what my table looks like, P2 being the latest time period, P1 being the previous time period.

kennym9_1-1646872089784.png

 


Any help with this dax function would be greatly appreciated as I'm still getting familiar with dax calculations. Thank You!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@kennym9 So like this?

Measure = 
  VAR __Period = MAX('Table'[Period Code])
  VAR __Model = MAX('Table'[Model)
  VAR __Color = MAX('Table'[Color)
  VAR __UnitsSold = MAX('Table'[Units Sold])
RETURN
  IF(__Period = "P1", BLANK(), __UnitsSold - MAXX(FILTER(ALL('Table'),__Period = "P1" && [Model] = __Model && [Color] = __Color),[Units Sold]))


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

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@kennym9 So like this?

Measure = 
  VAR __Period = MAX('Table'[Period Code])
  VAR __Model = MAX('Table'[Model)
  VAR __Color = MAX('Table'[Color)
  VAR __UnitsSold = MAX('Table'[Units Sold])
RETURN
  IF(__Period = "P1", BLANK(), __UnitsSold - MAXX(FILTER(ALL('Table'),__Period = "P1" && [Model] = __Model && [Color] = __Color),[Units Sold]))


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...

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.