Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX for Percentage Based on Three Status'

I am putting together a report to show the percentage of time a person spends working in office compared to working from home. My table includes the persons name, date and the status; In Office (IO)...
  • visheshjain's avatar
    visheshjain
    3 years ago

    Hi Anonymous,

     

    So this makes the problem a bit clear.

    My suggestion in this case would nbe to get rid of the blanks in your data inside power query, unless you absolutely need the for some reason.

     

    Next you can just use the following code to:

    1. get the total number of times people have worked IO, which is 19

    2. Get the total number of time people have worked IO or WFH, which is 65 (not 104, since we are not counting OOO). The double pipe symbol || stand for or condition

    3. Divide the 2 numbers. (19/65 = 29.23%)

     

     

     

    IO % = 
    var IO_Count = CALCULATE(COUNTROWS(Nata), FILTER(Nata, Nata[Status]="IO"))
    var Total_Count = CALCULATE(COUNTROWS(Nata), FILTER(Nata, Nata[Status]="IO" || Nata[Status]="WFH"))
    Return
    DIVIDE(IO_Count,Total_Count)

     

     

     

    Since in the total you have a filter for only WFH or IO, even if the blanks are present, it should not be a problem, as they will be filtered out.

     

    I hope this solves your problem and if it does then please do mark it as the solution, so that others can reach the solution faster.

     

    P.S. - I was working on some other solution and added your table to that solution, hence the table is named "Nata". Apologies!

     

    Thank you,

    Vishesh Jain