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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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. 


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

@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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors