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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Conditional Aggregate within Matrix

I'd like to create a calculation within a matrix similar the following. Rows are Cohort, columns are Year and values in the matrix cells are based on the following logic: if Year == 2020 then average(Value 3) else sum(Value 1) / sum(Value 2) end

 

My data looks similar to the following.

 

CohortYearValue 1Value 2Value 3
201620160.821430.306160.791628
210721070.5471360.3759040.088427
201820180.5665490.8466550.263815
201920190.0914740.6030610.371852
201620160.4784720.3275950.351641
210721070.6027570.4226310.773349
201820180.9547780.7229170.079683
201920190.0207410.9427760.908014
201620200.7917730.6781280.727963
210720200.834480.5516550.873079
1 ACCEPTED SOLUTION

@Anonymous as my friend @Greg_Deckler recommend, it has to be measure, if you are use Year , you have to provide aggregation for year

 

if(MAX( year ) = 2020, average(value 3), sum(value 1) / sum(value 2))

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Sounds like you need a measure.


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!:
The Definitive Guide to Power Query (M)

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

Measures seems to disagree as near as I can tell.. When I try entering a formula similar to: if(year = 2020, average(value 3), sum(value 1) / sum(value 2)) the formula bar wont even let me select the year column.

@Anonymous as my friend @Greg_Deckler recommend, it has to be measure, if you are use Year , you have to provide aggregation for year

 

if(MAX( year ) = 2020, average(value 3), sum(value 1) / sum(value 2))

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.