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
eugeneleefl
New Member

Converting test scores to letter grades in power BI

I am currently using Power BI for educational statistics. Basically, I have a table of numeric scores (e.g. 30, 40.5, 60, 99.4 etc) and I wish to add a new column in the Query Editor to convert these numbers into letter grades with the following rules:

 

A: 70 to 100

B: 65 to 69

C: 60 to 64

😧 55 to 59

E: 50 to 54

F: 49 and below

Is there a efficient way to do this as I have multiple columns to convert? Thanks. 

1 ACCEPTED SOLUTION
v-caliao-msft
Employee
Employee

@eugeneleefl,

 

There is no SWITCH function in Power Query, so the easiest way to do this is create calculated column by using DAX.
Column =
var xx = Table1[Amout]
return SWITCH(TRUE(),xx>=70&&xx<=100,"A"
,xx>=65&&xx<=69,"B"
,xx>=60&&xx<=64,"C"
,xx>=55&&xx<=59,"D"
,xx>=50&&xx<=54,"E"
,xx<=49,"F")

 

Regards,

Charlie Liao

View solution in original post

1 REPLY 1
v-caliao-msft
Employee
Employee

@eugeneleefl,

 

There is no SWITCH function in Power Query, so the easiest way to do this is create calculated column by using DAX.
Column =
var xx = Table1[Amout]
return SWITCH(TRUE(),xx>=70&&xx<=100,"A"
,xx>=65&&xx<=69,"B"
,xx>=60&&xx<=64,"C"
,xx>=55&&xx<=59,"D"
,xx>=50&&xx<=54,"E"
,xx<=49,"F")

 

Regards,

Charlie Liao

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.

Top Solution Authors
Top Kudoed Authors