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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Calculated Column with multiple AND & OR

Hi, 

I need to create a calculated column with the following rules: 

Write 1 IF:
Project is within G0 to G5 and status is 1 and description field is blank 
OR (Project is within G0 to G5 and status is 2 and description field is blank)
OR (Project is within G0 to G5 and status is 0)
ELSE 0

I have tried the following statement but so far I haven't found a solution that works
Hope someone can help.

 

Overall Status =
    IF(
        AND(
                    OR(
                    Initiatives[Stage] = "Demand Qualification"  ||
                    Initiatives[Stage] = "G0 Approval" ||
                    Initiatives[Stage] = "G1 Approval" ||
                    Initiatives[Stage] = "G2 Approval" ||
                    Initiatives[Stage] = "G3 Approval" ||
                    Initiatives[Stage] = "G4 Approval" ||
                    Initiatives[Stage] = "G5 Approval",
                    AND(Initiatives[Status] = 1, Initiatives[Description] = BLANK())),
                   
                    AND(
                    Initiatives[Stage] = "Demand Qualification"  ||
                    Initiatives[Stage] = "G0 Approval" ||
                    Initiatives[Stage] = "G1 Approval" ||
                    Initiatives[Stage] = "G2 Approval" ||
                    Initiatives[Stage] = "G3 Approval" ||
                    Initiatives[Stage] = "G4 Approval" ||
                    Initiatives[Stage] = "G5 Approval",
                    AND(Initiatives[Status] = 2, Initiatives[Description] = BLANK()))),
                   
                    AND(
                    Initiatives[Stage] = "Demand Qualification"  ||
                    Initiatives[Stage] = "G0 Approval" ||
                    Initiatives[Stage] = "G1 Approval" ||
                    Initiatives[Stage] = "G2 Approval" ||
                    Initiatives[Stage] = "G3 Approval" ||
                    Initiatives[Stage] = "G4 Approval" ||
                    Initiatives[Stage] = "G5 Approval",
                    Initiatives[Status] = 0)),1,0)



1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Anonymous try this:

 

 

 

Overall Status =
IF(
	Initiatives[Stage] 
		IN {
			"Demand Qualification", 
			"G0 Approval", 
			"G1 Approval", 
			"G2 Approval",
			"G3 Approval",
			"G4 Approval",
			"G5 Approval"
		},
		IF(
			Initiatives[Status] = "0", 
			1,
			IF(
				Initiatives[Status] IN {"1","2"}
					&& Initiatives[Description] = BLANK().
				1,
				0
			)
		)
)	
				

 

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

View solution in original post

6 REPLIES 6
SpartaBI
Community Champion
Community Champion

@Anonymous try this:

 

 

 

Overall Status =
IF(
	Initiatives[Stage] 
		IN {
			"Demand Qualification", 
			"G0 Approval", 
			"G1 Approval", 
			"G2 Approval",
			"G3 Approval",
			"G4 Approval",
			"G5 Approval"
		},
		IF(
			Initiatives[Status] = "0", 
			1,
			IF(
				Initiatives[Status] IN {"1","2"}
					&& Initiatives[Description] = BLANK().
				1,
				0
			)
		)
)	
				

 

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Anonymous
Not applicable

Hi Sparta, 

Thanks for you reply. 
When I try the provided solution I get the following error message:
Function 'CONTAINSROW' does not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.


Any idea of how to get around that ?

I think because your status column is a text, I'm adding "" around the relevant places in the original messages, you will see this in a minute

Anonymous
Not applicable

You were right with the status code column beeing text. 
But still think there are something wrong with you code.
E.g. a project with Initiatives[Stage] = G2 Approval and
Initiatives[Status] = 1 and Describtion BLANK will be assigned with 0

Anonymous
Not applicable

Sorry. It was me messing up with a column name. It seems to work flawlessly! Thanks alot

@Anonymous my pleasure 🙂
Will appreciate your Kudos 🙂
P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. Please give it a thumbs up over there if you liked it 🙂
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.