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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
MClipsham92
Frequent Visitor

IF statement with variable not working as expected

Hello All,

 

I have this code: 

Overall Score Improved Term 2 = VAR a= IF('Link Teacher'[Attribute]="Link Teacher Score 3",MAXX(FILTER('Link Teacher','Link Teacher'[Identifier]=EARLIER('Link Teacher'[Identifier])&&'Link Teacher'[Attribute]="Link Teacher Score 2"),'Link Teacher'[Score]))
return if(ISBLANK(a),BLANK(),if('Link Teacher'[Score]<a,"Did not improve",IF('Link Teacher'[Score]=a,"Stayed the same","Improved")))

That returns a Did not improve/Stayed the Same/Improved text value depedning on whether or a students score has increased in a certain attribute between the 3rd assessment point and the second. (Link Teacher score 3 and Link Teacher score 2)

 

However it does not appear to be returning the right value for all students, I have one student that has a score of 13 at the Link Teacher Score 2 but a score of 8 at Link Teacher Score 3. The code erroneously marks him as having Improved which clearly he has not.

 

Any ideas on this? I'm confused because it appears to be marking the majority of students correctly.

 

My data looks like:

 

StudentIdentifierAttributeScore
Student 1Student 1Link Teacher Score 213
Student 1Student 1Link Teacher Score 38

 

 

Many Thanks,

 

Mark Clipsham.

1 ACCEPTED SOLUTION
MClipsham92
Frequent Visitor

Think I've worked it out, I had the scores classified as Text data type rather than whole number for some reason.

 

Thanks,

 

Mark.

View solution in original post

1 REPLY 1
MClipsham92
Frequent Visitor

Think I've worked it out, I had the scores classified as Text data type rather than whole number for some reason.

 

Thanks,

 

Mark.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.