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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Libbya
New Member

IF Statement help

Hi I have created a new column and now trying to create the following If statement to return either 1,2 or 3 in the new column but get a syntax error message. Any suggestions?  
 
Qtr1 Results = IF('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Green],"1",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Amber],"2",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Red]="3"))))
 
Thanks
1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Libbya 

pls try this

Qtr1 Results = IF('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Green],"1",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Amber],"2",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Red],"3")))

 

the last equal sign is wrong, should be comma.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Libbya ,

 

I agree with @ryan_mayu . And there is another doubt, whether your [Green], [Amber] and [Red] are text, or a column, if it is text, please use double quotes to quote the text. For example,

Qtr1 Results =
IF (
    'Tier 2 FY23'[Qtr1] = "Green",
    "1",
    IF (
        'Tier 2 FY23'[Qtr1] = "Amber",
        "2",
        IF ( 'Tier 2 FY23'[Qtr1] = "Red", "3" )
    )
)

 

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@Libbya 

pls try this

Qtr1 Results = IF('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Green],"1",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Amber],"2",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Red],"3")))

 

the last equal sign is wrong, should be comma.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Libbya , try like

Qtr1 Results = IF('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Green],"1",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Amber],"2",If('Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Red]="3")))

 

 

Or Try Switch

 

Qtr1 Results = Switch(True() ,
'Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Green],"1",
'Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Amber],"2",
'Tier 2 FY23'[Qtr1]='Tier 2 FY23'[Red]="3")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.