Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago

Calculating percentages and distinct counts

I'm looking for a way for Power BI to calculate percentages by comparing two #'s together.    I'm also looking for a way these two #'s are the results of a distinct count.    Example, column #1 has 6 occurrences of the word "Red"; column #2 has 2 occurrences of the word "Blue".    I'd like the column #3 and #4 display the output ("6" and "2") and finally, column #5 and #6 display the percentage of occurrence that Red and Blue appear in the list.   I need for the report to dynamically calculate as there will be a slicer in this report which will drive the content to filter on.       

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous,

    Please check if the following DAX return your expected result. If not, please help to share sample data of your table.

    Column3 = CALCULATE(COUNTA(Table[Column1]),FILTER(Table,Table[Column1]="Red"))
    Column4 = CALCULATE(COUNTA(Table[Column2]),FILTER(Table,Table[Column2]="Blue"))
    % of Red = Table6[Column3]/COUNT(Table6[Column1])
    % of Blue = Table6[Column4]/COUNT(Table6[Column2])


    Regards,
    Lydia Zhang