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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to get percentage?

This seems a bit silly, but my measures on percentage is showing odd figures. I have a column, with a "Yes" or "No" values. I did the following to extract the number of "Yes" values:

* Yes  Measure = (CALCULATE(DISTINCTCOUNT(Merge1[_msfpvalueid]),Merge1[heard of us?]="Yes"))
Then to get the percentage of "Yes" values in the column, i did the following:
* Yes % =  [Yes  Measure]/COUNTA(Merge1[[heard of us?] ), with percenatge formate.
 
It returns the right percentage, but when I select NO in a slicer, it returns something like 385%, instead of the expected  "0" or blank.
What I'm I doing wrong here?
2 ACCEPTED SOLUTIONS

 

Here you go my friend. Please accept this as correct if this meets your requirements

Edit:

Slightly modified the TotalifYes variable Smiley Wink

 

CountofYesHeard = CALCULATE(COUNTA('Table'[Heardofus?]), 'Table'[Heardofus?] = "Yes") 
TotalCounts = 
VAR choice = SELECTEDVALUE('Table'[Heardofus?])
VAR TotalifYes = [CountofYesHeard],
VAR Total = 
CALCULATE
(
    COUNTA('Table'[Heardofus?]),
    all('Table'[Heardofus?])
)
RETURN
SWITCH
(
    choice,
    "No",BLANK(),
    "Yes", TotalifYes,
    Total
)
% heard = DIVIDE([CountofYesHeard],[TotalCounts], BLANK())

 

View solution in original post

@Anonymous 

 

Hi, try with this:

 

CountYes = CALCULATE(COUNTA(Table1[A]),FILTER(Table1,Table1[B]="yes"))
%Yes of Total = DIVIDE([CountYes],CALCULATE(COUNTA(Table1[A]),ALLSELECTED(Table1)))

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

12 REPLIES 12

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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