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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Similar function like group by and countif

Hi all,

 

I've been struggling to find a solution for my problem.

Below is the simplified data sample of what I'm trying to do.

ChainStoreIDItemQuestionTargetActual
TescoT1AA111
TescoT1AA210
TescoT1AA311
TescoT2AA111
TescoT2AA211
TescoT2AA311
TescoT1BB111
TescoT1BB211
TescoT1BB311
TescoT2BB110
TescoT2BB210
TescoT2BB310
LidlL1AA111
LidlL1AA211
LidlL1AA311
LidlL2AA111
LidlL2AA211
LidlL2AA311
LidlL1BB111
LidlL1BB211
LidlL1BB311
LidlL2BB110
LidlL2BB210
LidlL2BB310

 

I'm trying to use matrix visualization to get something like this:

2def9311-c887-4020-95f7-8dde0e40ad6a.jpg

Where Chain, Item, and Questions are rows of the matrix. The values of Target and Actual on the Question level are simply the sum of Target and Actual from the table. However, I want the Target and Actual on the Item level to be the number of stores that have all-hit (A1, A2, and A3 are equal to 1, etc) for that particular item. Whereas the Target and Actual on the Chain level to be the sum of Target and Actual on the Item level.

 

 

 

 

 

 

 

 

 

 

If I just drag fields to matrix visualization without using custom measure, it looks like below, which is not something I'm looking for.

e566e63e-006d-4451-b0a2-5e9a1b0d3177.jpg

 

My idea is to groupby based on StoreID and do sum aggregate on the Target and Actual, and then countif the Actual = Target, but I don't know how to do this using DAX.

Does anyone have a solution for this?

 

Thank you!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8

 

Also, I think this specifically will help: Matrix Measure Total Triple Threat Rock & Roll - Microsoft Power BI Community


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@Anonymous First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8

 

Also, I think this specifically will help: Matrix Measure Total Triple Threat Rock & Roll - Microsoft Power BI Community


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.