Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello Everyone,
I am trying to create a column with DAX expression that inputs Yes when a student fails an exam for a certain period. For example, I have the following table
| Name | Exam | Exam Score |
| Steve | Exam 1 | Fail |
| Steve | Exam 2 | Pass |
| Steve | Exam 3 | Pass |
| Bob | Exam 1 | Pass |
| Bob | Exam 2 | Fail |
| Bob | Exam 3 | Fail |
| Jeff | Exam 1 | Fail |
| Jeff | Exam 2 | Fail |
| Jeff | Exam 3 | Fail |
I wanted to create an additional column called Exam 1 Fail? and it will put Yes for each row if they failed Exam 1. The result table would be:
| Name | Exam | Exam Score | Exam 1 Fail? |
| Steve | Exam 1 | Fail | Yes |
| Steve | Exam 2 | Pass | Yes |
| Steve | Exam 3 | Pass | Yes |
| Bob | Exam 1 | Pass | No |
| Bob | Exam 2 | Fail | No |
| Bob | Exam 3 | Fail | No |
| Jeff | Exam 1 | Fail | Yes |
| Jeff | Exam 2 | Fail | Yes |
| Jeff | Exam 3 | Fail | Yes |
How would I go about doing this? I have tried IF statements but I'm having a tough time finding the correct logic that would but Yes for each row. Any help is much appreciated and let me know if I can clarify.
Solved! Go to Solution.
Hi @botaac
You could use something like this.
Fail exam 1 =
VAR Student = Exams[Name]
VAR Resultexam1 = COUNTROWS(
FILTER( Exams, Exams[Name] = Student && Exams[Exam] = "Exam 1" && Exams[Exam Score] = "Fail"))
RETURN
If(Resultexam1 = 1,"Yes","No")Best regards,
Jeroen
Hi,
This calculated column formula works
=if(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[Name]=EARLIER(Data[Name])&&Data[Exam]="Exam 1"&&Data[Exam Score]="Fail"))>=1,"Yes","No")
Hope this helps.
Hi @botaac
You could use something like this.
Fail exam 1 =
VAR Student = Exams[Name]
VAR Resultexam1 = COUNTROWS(
FILTER( Exams, Exams[Name] = Student && Exams[Exam] = "Exam 1" && Exams[Exam Score] = "Fail"))
RETURN
If(Resultexam1 = 1,"Yes","No")Best regards,
Jeroen
That is awesome! Thank you so much, Jeroen. Have a nice day!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 45 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 67 | |
| 66 | |
| 31 | |
| 28 | |
| 24 |