Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
botaac
Frequent Visitor

Input Yes for whole column

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

 

NameExamExam Score
SteveExam 1Fail
SteveExam 2Pass
SteveExam 3Pass
BobExam 1Pass
BobExam 2Fail
BobExam 3Fail
JeffExam 1Fail
JeffExam 2Fail
JeffExam 3Fail

 

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:

 

NameExamExam ScoreExam 1 Fail?
SteveExam 1FailYes
SteveExam 2PassYes
SteveExam 3PassYes
BobExam 1PassNo
BobExam 2FailNo
BobExam 3FailNo
JeffExam 1FailYes
JeffExam 2FailYes
JeffExam 3FailYes

 

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.

1 ACCEPTED SOLUTION
jeroendekk
Resolver V
Resolver V

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")

Schermafbeelding 2021-11-20 161421.jpg

Best regards,

Jeroen

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

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.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jeroendekk
Resolver V
Resolver V

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")

Schermafbeelding 2021-11-20 161421.jpg

Best regards,

Jeroen

That is awesome! Thank you so much, Jeroen. Have a nice day!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.