Forum Discussion
Anonymous
7 years agoNot 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...
- Anonymous7 years ago
Here you go my friend. Please accept this as correct if this meets your requirements
Edit:
Slightly modified the TotalifYes variable :smileywink:
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())
- 7 years ago
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
Anonymous
7 years agoNot applicable
hi Anonymous , we are almost there, I used your images 1, 3 and 4. now regardless of any selection in the slicer, its always showing 100% and when i select "NO", it returns a blank. I want it showing the percentage of yes, when nothing is selected, when "Yes" is selected, it should show 100% and when "NO" is selected, i should get blank. Can this done ?
Anonymous
7 years agoNot applicable
Here you go my friend. Please accept this as correct if this meets your requirements
Edit:
Slightly modified the TotalifYes variable :smileywink:
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())
- Anonymous7 years agoNot applicable
Thanks Anonymous , appreciate.