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

DAX calculation

KSC_0-1652881292554.png

 

In the above table i want a column "Overall Status" next to Status, which should show 'Pass' or 'Fail' for each Name.
Condition : Show 'Pass' only if the person have Pass in all subject else show 'Fail' in "Overall Status"

1 ACCEPTED SOLUTION

Hey @Anonymous ,

 

sure, you can expant the criteria for other cases.

You could separate them with the double pipe "||" or you use the IN operator:

Overall Status =
IF (
    CALCULATE (
        COUNTROWS ( MyTable ),
        ALLEXCEPT ( MyTable, MyTable[Name] ),
        MyTable[Status] IN { "Fail", "N/A", BLANK () }
    ) > 0,
    "Fail",
    "Pass"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
 

View solution in original post

10 REPLIES 10
rohit_singh
Solution Sage
Solution Sage

Hello @Anonymous ,

Try this calculated column in DAX :

rohit_singh_0-1652882208234.png

Overall Status =

var _grades =
CALCULATE(
CONCATENATEX(VALUES(Grades[Status]), Grades[Status]," , "),
ALLEXCEPT(Grades, Grades[Name])
)

RETURN
if (CONTAINSSTRING(_grades, "Fail"), "Fail", "Pass" )
 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊

Anonymous
Not applicable

Hi @rohit_singh 
In the above scenario i also want to check if any "Status" value for the "Name" is blank or N/A then also "Overall Status" should show "Fail"

Note
: blank is not string, its just empty column.

Anonymous
Not applicable

can you please confirm what should i put at highlight text
if (CONTAINSSTRING(_grades"Fail"), "Fail""Pass" )

Hi @Anonymous ,

_grades is a a variable that we have created. 

var _grades =
CALCULATE(
CONCATENATEX(VALUES(Grades[Status]), Grades[Status]," , "),
ALLEXCEPT(GradesGrades[Name])
)
 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊

Anonymous
Not applicable

Big Thank
just last help if its possible to show only one value for each Name in Overall status
Currently its showing for each status row.

For each name there should be only one Overall status value, not repeating values.

KSC_0-1652887891113.png

 

selimovd
Super User
Super User

Hey @Anonymous ,

 

as I understood you want it as a calculated column.

Then the following approach would work:

Overall Status = 
IF (
    CALCULATE (
        COUNTROWS ( MyTable ),
        ALLEXCEPT ( MyTable, MyTable[Name] ),
        MyTable[Status] = "Fail"
    ) > 0,
    "Fail",
    "Pass"
)

 

The result would look like that:

selimovd_0-1652881904182.png

 

You could also solve that with a measure.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

 

Anonymous
Not applicable

Hi @selimovd 
In the above scenario i also want to check if any "Status" value for the "Name" is blank or N/A then also "Overall Status" should show "Fail"

Note
: blank is not string, its just empty column.

Hey @Anonymous ,

 

sure, you can expant the criteria for other cases.

You could separate them with the double pipe "||" or you use the IN operator:

Overall Status =
IF (
    CALCULATE (
        COUNTROWS ( MyTable ),
        ALLEXCEPT ( MyTable, MyTable[Name] ),
        MyTable[Status] IN { "Fail", "N/A", BLANK () }
    ) > 0,
    "Fail",
    "Pass"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
 

Hi @Anonymous 

 

I'd like to make a small modification based on @selimovd 's solution. Replace BLANK() with "". 

vjingzhang_0-1654242129242.png

 

Best Regards,
Community Support Team _ Jing

Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

 

Create a column as below:-

 

Overall status = 
    var result = COUNTROWS(FILTER('Table','Table'[status] = "Fail" && 'Table'[Name]= EARLIER('Table'[Name])))
    return IF(result>0,"Fail","Pass")

 

Output:-

Samarth_18_1-1652881885247.png

 

Regards,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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.