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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Conditional Column based on values of other columns

So I have three columns of data called 'Page 1' 'Page 2' and 'Page 3'.

I want a Custom column to first look at Page 1 and if it doesn't contain the word "Test", Custom column should populate with the contents of Page 1.

If it does contain the word "Test", it should then look at Page 2.

If Page 2 is not blank then Custom column should populate with the content of Page 2.

If it is blank then Custom column should populate with the content of Page 3. 

 

I have used the code below, but it's not working properly see attached where in red my logic isn't being applied.  = 

 

Table.AddColumn(#"Filtered/", "Custom", each if [Page 1] = "Test" then [Page 2] else if [Page 2] = null then [Page 3] else [Page 1])

Sample.png

1 ACCEPTED SOLUTION
Cmcmahan
Resident Rockstar
Resident Rockstar

 

Looks like your IF statement is evaluating in an order you aren't expecting.  If Page 1 is not equal to test, the next logic it tries to apply is the if Page 2 = null logic.

 

Try this instead:

Table.AddColumn(#"Filtered/", "Custom", each 
if [Page 1] = "Test" then
if [Page 2] = null then [Page 3]
else [Page 2]
else [Page 1]
)

 

 

View solution in original post

1 REPLY 1
Cmcmahan
Resident Rockstar
Resident Rockstar

 

Looks like your IF statement is evaluating in an order you aren't expecting.  If Page 1 is not equal to test, the next logic it tries to apply is the if Page 2 = null logic.

 

Try this instead:

Table.AddColumn(#"Filtered/", "Custom", each 
if [Page 1] = "Test" then
if [Page 2] = null then [Page 3]
else [Page 2]
else [Page 1]
)

 

 

Helpful resources

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

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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