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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Bansi008
Helper II
Helper II

Need help on Power BI Query.

Hi team, I am currently working on my borganizational project and i am trying to create new measure for my database using below query. However i can't able to add new measure due to syntax error. Can someone please help me.

 

Risk Level = var Impact = AVERAGE(Output[RiskImpact])
var Likelihood = AVERAGE(Output[RiskLikelihood])
return
SWITCH(TRUE() ,
Impact > 0 && Impact <= 2 && Likelihood > 0 && Likelihood <=4 , "LOW" ,
Impact > 0 && Impact <= 2 && Likelihood > 4 && Likelihood <=5 , "MEDIUM" ,
Impact > 2 && Impact <= 3 && Likelihood > 0 && Likelihood <=4 , "MEDIUM" ,
Impact > 2 && Impact <= 3 && Likelihood > 4 && Likelihood <=5 , "HIGH" ,
Impact > 3 && Impact <= 4 && Likelihood > 0 && Likelihood <=3 , "MEDIUM" ,
Impact > 3 && Impact <= 4 && Likelihood > 3 && Likelihood <=5 , "HIGH" ,
Impact > 4 && Impact <= 5 && Likelihood > 0 && Likelihood <=1 , "MEDIUM" ,
Impact > 4 && Impact <= 5 && Likelihood > 1 && Likelihood <=5 , "HIGH" ,
"NA” )
2 REPLIES 2
Vijay_A_Verma
Super User
Super User

Problem is about second quote in the formula for NA. In place of "NA” use "NA"

Hence following formula would work

 

Risk Level = 
var Impact = AVERAGE(Output[RiskImpact])
var Likelihood = AVERAGE(Output[RiskLikelihood])
return
SWITCH(TRUE() ,
Impact > 0 && Impact <= 2 && Likelihood > 0 && Likelihood <=4 , "LOW" ,
Impact > 0 && Impact <= 2 && Likelihood > 4 && Likelihood <=5 , "MEDIUM" ,
Impact > 2 && Impact <= 3 && Likelihood > 0 && Likelihood <=4 , "MEDIUM" ,
Impact > 2 && Impact <= 3 && Likelihood > 4 && Likelihood <=5 , "HIGH" ,
Impact > 3 && Impact <= 4 && Likelihood > 0 && Likelihood <=3 , "MEDIUM" ,
Impact > 3 && Impact <= 4 && Likelihood > 3 && Likelihood <=5 , "HIGH" ,
Impact > 4 && Impact <= 5 && Likelihood > 0 && Likelihood <=1 , "MEDIUM" ,
Impact > 4 && Impact <= 5 && Likelihood > 1 && Likelihood <=5 , "HIGH",
"NA")

 

Thank you Vijay. This is works.

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.