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
sunilbeckham
Helper I
Helper I

Changing measure calculation based on Column values.

Hello everyone

 

I have a student table similar to the below dummy columns that I'm trying to create a measure for. I'm trying to create a measure that will change it's calculation depending on the values in the column "Completion Years". The intent is to create a measure which will show the percentage of students, but the denominator will change depending on the column values of "File Source". Here's the measure that I have created so far:

 
Graduation Rate =
SWITCH(TRUE(), student[Completion Years] = "3 Years", DIVIDE(CALCULATE(COUNTA(student[Student Number]),student[Graduation Status] = "OT",student[Source] = "On Time"),CALCULATE(COUNTA(student[Student Number]),student[Graduation Status] = "OT",student[Source] = "On Time")),student[Completion Years] IN{ "4 Years","5 Years"},DIVIDE(CALCULATE(COUNTA(student[Student Number]),student[Graduation Status] IN {"OT", "ET"},student[Source] = "Extended Time"),CALCULATE(COUNTA(student[Student Number]),student[Graduation Status] IN {"OT","ET"} ,student[Source] = "Extended Time")),student[Completion Years])
 
However, the intellisence is not picking up the column name "Completion Years". Is there something that I'm missing out on?
Any help would be much appreciated.
Thanks.

 

Student NumberGraduation StatusSourceCompletion Years
101OTOn Time3 Years
102OTOn Time3 Years
103ETExtended Time4 Years
104ETExtended Time5 Years
105ETExtended Time5 Years

 

1 ACCEPTED SOLUTION
onurbmiguel_
Super User
Super User

hi @sunilbeckham 

Try this measure: 

VAR _compl_year = SELECTEDVALUE( Student[Completion Years] )
VAR _value =
    SWITCH(
        TRUE( ),
        _compl_year = "3 Years",
            DIVIDE(
                CALCULATE( COUNTA( Student[Student Number] ), Student[Graduation Status] = "OT", Student[Source] = "On Time" ),
                CALCULATE( COUNTA( Student[Student Number] ), Student[Graduation Status] = "OT", Student[Source] = "On Time" )
            ),
        _compl_year IN { "4 Years", "5 Years" },
            DIVIDE(
                CALCULATE(
                    COUNTA( Student[Student Number] ),
                    Student[Graduation Status] IN { "OT", "ET" },
                    Student[Source] = "Extended Time"
                ),
                CALCULATE(
                    COUNTA( Student[Student Number] ),
                    Student[Graduation Status] IN { "OT", "ET" },
                    Student[Source] = "Extended Time"
                )
            ),
        BLANK( )
    )
RETURN
    _value

 

 

Best regards

Bruno Costa | Power Participant

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍


You can also check out BI4ALL's website and our data solutions!

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


View solution in original post

2 REPLIES 2
onurbmiguel_
Super User
Super User

hi @sunilbeckham 

Try this measure: 

VAR _compl_year = SELECTEDVALUE( Student[Completion Years] )
VAR _value =
    SWITCH(
        TRUE( ),
        _compl_year = "3 Years",
            DIVIDE(
                CALCULATE( COUNTA( Student[Student Number] ), Student[Graduation Status] = "OT", Student[Source] = "On Time" ),
                CALCULATE( COUNTA( Student[Student Number] ), Student[Graduation Status] = "OT", Student[Source] = "On Time" )
            ),
        _compl_year IN { "4 Years", "5 Years" },
            DIVIDE(
                CALCULATE(
                    COUNTA( Student[Student Number] ),
                    Student[Graduation Status] IN { "OT", "ET" },
                    Student[Source] = "Extended Time"
                ),
                CALCULATE(
                    COUNTA( Student[Student Number] ),
                    Student[Graduation Status] IN { "OT", "ET" },
                    Student[Source] = "Extended Time"
                )
            ),
        BLANK( )
    )
RETURN
    _value

 

 

Best regards

Bruno Costa | Power Participant

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍


You can also check out BI4ALL's website and our data solutions!

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


This was really helpful.

Thank you so much for your time and input.

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.