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
shelbsassy
Resolver I
Resolver I

Percent of Total based on Flags

I am trying to get the % of members for each flag from the total number of members.  I have a measure # of members which is a Distinct count of membid.  When I display the Flag with # members it shows the members for each flag and then using the same # memebrs in a separate visual I show the total number of memebrs for the moth.  I am tryng to calculate the % of the memebrs for each flag out of the months total members.  I have tried a few things but I am pretty new at this.  I am stuck.  Any help would be awesome, thank you!

1 ACCEPTED SOLUTION

After many trials and tribulations I finally got it to work.  Not sure I understand the logic but I'll take it.  Thanks for the help!

 

PercentMembers = CALCULATE('Members Claims'[# Members]/CALCULATE('Members Claims'[# Members],ALLEXCEPT('Members Claims','Members Claims'[Carrier_id])))

View solution in original post

13 REPLIES 13
Greg_Deckler
Super User
Super User

I believe there is a Quick Measure for % of Total.


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

Unfortunately the quick measure only works to get the % of the total that were flagged.  I need the % of all the members, not just the ones flagged.

How about creating a measure like this:

 

Measure1 = [Measure] / CALCULATE([Measure],ALL(Table))

Something like that, where [Measure] is your existing measure and Table would be the table that your measure deals with. The ALL removes all filter context and thus would grab all of the members regardless of Flag.


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

Thank you, I tried that and it didn't work.  I need to keep the flags filter on it so I even tried removing the ALL but I end up with 100% for each column.  Here is a picture of what I am trying to calculate. The number of memebrs from the flags divided by the # members.  I just cant seem to make it work.Untitled.png

For example, what I did to mock this up was this:

 

Member,Flag

1Flag1
2Flag1
3Flag1
4Flag1
5Flag2
6Flag2
7Flag2
8Flag3
9Flag3
10Flag4

 

Created these measures:

 

MemberFlagCount = COUNT([Member])

PercentMembers = [MemberFlagCount]/CALCULATE([MemberFlagCount],ALL('Members'))

 


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

I tried this but i get the cant display the visual.

 

PercentMembers = calculate('Members Claims'[# Members]('Members Claims'[Flag])/'Members Claims'[# Members])

Can't do much without sample data but your formula does not look right at all. CALCULATE takes 2 parameters, what you want to calculate and then a filter. I don't see a comma in your formula so I have to believe that you are getting an error. Besides that, if that is a measure, you're going to need an aggregation like SUM or COUNT. See the measure formulas that I sent.


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

After many trials and tribulations I finally got it to work.  Not sure I understand the logic but I'll take it.  Thanks for the help!

 

PercentMembers = CALCULATE('Members Claims'[# Members]/CALCULATE('Members Claims'[# Members],ALLEXCEPT('Members Claims','Members Claims'[Carrier_id])))

Hi @shelbsassy,

Congratulations, you have resolved your issue by yourself. Please mark your solution as answer. So that other people benefit from it and find workaround clearly.

Thanks,
Angelia

Yep, that looks better. Your demoninator is calculating your measure in the context of all items in Members Claims except it is honoring any filter on Carrier_id column. The numerator calculates your measure in the full context of the filters on the visual/report/page.


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

Thank you for the explanation.  I was able to create 2 similar calculations using the logic from the explanation.  Appreciate the help!

I kind of see how this makes sense but Im not seeing where you are taking the filter of the Flag into play in the member flag count.  It looks like you are just counting the # members.  How can I count the number of members for a flag?

Please provide sample data.


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