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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
laurelning
Helper I
Helper I

How to create a new measure of % by group

Hi all,

    I am new to DAX and I believe this is a very simple question to the experts here. I have a survey question that asks customer to respond why they frequent a certain store and they can check multiple reasons. I have two data sets, one having the customer IDs and the reason; the other data file having again customer IDs and the stores they visited.  If, for example, we have a total of 10 customers, among them, 8 check location... how to get the percentage based on a total of 10 customers? Please see below the excel table that I would like to create instead in power bi.

why.png

The sample data is here to download :

https://drive.google.com/open?id=19NYmpV0ulE_Hhla0pCZFFcpFB56mXmI7

 

Thanks in advance and your help is highly appreciated!

 

Laurel

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Here's the full and correct solution. The answer does not lie in DAX. It lies in the data model.

 

https://1drv.ms/u/s!ApyQEauTSLtOgYM53H8bs_VEwonrUA?e=1mhVYz

 

Best

D

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Sure,

 

Measure = DIVIDE(COUNTROWS('Sheet1'),COUNTROWS(DISTINCT(ALL(Sheet2[Customer ID]))),0)

 

PBIX is attached. 



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Thanks for helping out. I look forward to learning from your book. Maybe I haven't explained clear enough in the first post. The exact excel table I look for in power bi is :

why3excel.png

And the measure created gives me the following:

why2.png

I hope to have the percentage of reasons by stores. 

 

Thanks.

 

Laurel

Anonymous
Not applicable

Here's the full and correct solution. The answer does not lie in DAX. It lies in the data model.

 

https://1drv.ms/u/s!ApyQEauTSLtOgYM53H8bs_VEwonrUA?e=1mhVYz

 

Best

D

@Anonymous  Thanks! It works and serves the purpose. I was ablto to follow your example and replicate it to my very complex data. There is still a place that doesn't come back to be right though. Also I am wondering if there is way that we can make it work simpler. Will come back to you with more questions. Thanks again for your time!

 

Great to have the community here to support!

 

Ling

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.