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

Divide a column by itself with filters

Hi guys,

 

Wondering if you can assist. I have a table with a column called Result. 

 

Within the Result column, there are values such as:

 

Satisfactory

Did Not Attend

Poor

Excellent

 

I would like to create a measure that allows me to see the % of those who achieved 'Satisfactory' / over everyon who sat the exam. As there are values of Did not Attend, I will need to filter that out when dividing. 

 

SUM 'RESULT' WITH VALUE = SATISFACTORY / SUM ' RESULT' SATISFACTORY &  POOR & EXCELLENT.

 

How can i do this, because I keep coming up with errors. I have tried SUM and COUNT but cannot get my head around the filtering part.

 

Any guidance would be much apprecaited. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous -

The following divides the selected result by all of the results, except for "Did Not Attend":

 

% Selected Result = 
DIVIDE(
    COUNTROWS(Exam),
    CALCULATE(
        COUNTROWS(Exam),
        Exam[Result] <> "Did Not Attend"
    )
)

The following divides "Satisfactory" in particular by everything except "Did Not Attend":

% Selected Result = 
DIVIDE(
    CALCULATE(
        COUNTROWS(Exam),
        Exam[Result] = "Satisfactory"
    ),
    CALCULATE(
        COUNTROWS(Exam),
        Exam[Result] <> "Did Not Attend"
    )
)

The second parameter of "CALCULATE" changes the "filter context".

Hope this helps,

Nathan

 

 

View solution in original post

5 REPLIES 5
vanessafvg
Super User
Super User

@Anonymous  create a measure

% of those who achieved 'Satisfactory' =
VAR satistfatory =
    CALCULATE ( COUNTROWS ( tablename ), result = "satisfactory" )
VAR all =
    CALCULATE ( COUNTROWS ( tablename ) )
RETURN
    DIVIDE ( satsifactory, all )
 
is one way of doing it




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

But we cannot divide by all, we need to filter out the do not attend. 

Anonymous
Not applicable

@Anonymous -

The following divides the selected result by all of the results, except for "Did Not Attend":

 

% Selected Result = 
DIVIDE(
    COUNTROWS(Exam),
    CALCULATE(
        COUNTROWS(Exam),
        Exam[Result] <> "Did Not Attend"
    )
)

The following divides "Satisfactory" in particular by everything except "Did Not Attend":

% Selected Result = 
DIVIDE(
    CALCULATE(
        COUNTROWS(Exam),
        Exam[Result] = "Satisfactory"
    ),
    CALCULATE(
        COUNTROWS(Exam),
        Exam[Result] <> "Did Not Attend"
    )
)

The second parameter of "CALCULATE" changes the "filter context".

Hope this helps,

Nathan

 

 

Anonymous
Not applicable

Excellent, thanks a lot. This worked.

 

If i wanted to add another condition to the Does Not Contain, what is best practise?

 

Can I do as below?

 

& "Value"

Anonymous
Not applicable

@Anonymous  -

You could do the following:

% Selected Result = 
DIVIDE(
    COUNTROWS(Exam),
    CALCULATE(
        COUNTROWS(Exam),
        NOT Exam[Result] IN {"Did Not Attend", "Satisfactory"}
    )
)

 

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.