Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, I am trying to create a visual using if statements in DAX. I never get to understand and how to properly explain what Im after but, Ill try my best.
I want to create a visual table to check students exam results, and return a value to tell if that section passed or failed.
If Student 1 = Math, History, Science is passed, and Student 2 = Math, History, Science is passed. Then Section 1 passed.
Else if any of student failed one subject, then Section 1 has failed.
The table is this:
By using the table above, Im trying to calculate if Section 1 passed or failed like this:
Any help would be really great. I would love to know if this is possible.
Im having trouble because this is texts, and not numbers. Im unable to calculate the result.
Thank you so much everyone!
Solved! Go to Solution.
Hi @CarryASaw ,
Please follow these steps:
Since I wasn't very clear about the categorization of sections in your description, I created an extra column of sections as shown below:
1.Create the metric and write the following expression:
result =
VAR _count = COUNTX(FILTER(ALL('Table'),'Table'[Section] = MAX('Table'[Section])&&'Table'[Exam Result] = "Failed"),[Exam Result])
RETURN
IF(_count = BLANK(),"Passed","failed")
2.The result obtained is shown below:
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @CarryASaw ,
Please follow these steps:
Since I wasn't very clear about the categorization of sections in your description, I created an extra column of sections as shown below:
1.Create the metric and write the following expression:
result =
VAR _count = COUNTX(FILTER(ALL('Table'),'Table'[Section] = MAX('Table'[Section])&&'Table'[Exam Result] = "Failed"),[Exam Result])
RETURN
IF(_count = BLANK(),"Passed","failed")
2.The result obtained is shown below:
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
It worked.
Just a follow up question though, how do I add more filter?
I tried adding filter like this:
result =
VAR _count = COUNTX(FILTER(ALL('Table'),'Table'[Section] = MAX('Table'[Section])
&&
'Table'[Exam Result] = "Failed"),
'Table'[Exam Result] = "Not Yet Submitted")
,[Exam Result])
RETURN
IF(_count = BLANK(),"Passed","Failed")
I tried adding the "Not Yet Submitted" to be also considered as failed but no luck.
I tried to dabble with the code but DAX seems to find the results wrong even if I wrote it like this:
ExamsResult =
Var _count = COUNTX(FILTER(ALL('Sheet1'),
'Sheet1'[Subject] = MAX(Sheet1[Subject])
&&
Sheet1[Exam Result] = "Passed"),[Exam Result])
RETURN
IF(_count = BLANK(),"Failed","Passed")
I just tried to filter the passed instead, and reversed the return Failed if true, and Passed if false.
It seems it doesnt work like I thought it would be.
It Resulted to this:
To make it clear, I want to add another filter to make the result show it like this:
by using this new table:
Im sorry, I am new about this. I hope I explained my new problem properly. Thank you very much.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |