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
Anonymous
Not applicable

Conditional Column - Nested IF limit

Hi,

 

I ahve a coditional column with the following

 

#"Added Conditional Column" = Table.AddColumn(dbo_DFPWeekly, "Title", each if Text.Contains([Ad unit], "News and Star") then "News and Star" else if Text.Contains([Ad unit], "Hexham Courant") then "Hexham Courant" else if Text.Contains([Ad unit], "Cumberland News") then "Cumberland News" else if Text.Contains([Ad unit], "Whitehaven News") then "Whitehaven News" else if Text.Contains([Ad unit], "The Mail") then "The Mail" else if Text.Contains([Ad unit], "Go Active") then "Go Active" else if Text.Contains([Ad unit], "In Cumbria") then "In Cumbria" else if Text.Contains([Ad unit], "Clickin2") then "Clickin2" else if Text.Contains([Ad unit], "Pets") then "Pets" else if Text.Contains([Ad unit], "Clickin2Findit") then "Clickin2Findit" else if Text.Contains([Ad unit], "Eskdale") then "E&L" else if Text.Contains([Ad unit], "Live") then "Cumbria Live" else if Text.Contains([Ad unit], "CN Jobs") then "CN Jobs" else if Text.Contains([Ad unit], "Times and Star") then "Times and Star" else null)

 

Now there are still some more conditions to add but there seems to be a limit...?

 

This is not very helpful?  Any ideas/ways round it?  Possibly two statements?

7 REPLIES 7
dmark
New Member

I got the same problem and although it seems it's from SQL from that error, I believe it's a limitation with PowerBI December update instead.

 

If you go thru your Applied Steps highlighting the steps one after the other, the error does not occur (in my case) from the import of the source but more at the applied step where the Conditional Column was created that has more of a nested statement of 10.   Another verification for me, was if I reduce it below 10 the problem went away.  Mind you these steps occur after import of data to powerbi.

 

For me anyways, I reverted to the November version and the problem went away completly without making any changes.

 

 

coiter
Frequent Visitor

then they should offer a CASE WHEN/THEN of Conditional Columns instead of a nested IF when they did the december update.

 

I created custom views with CASE statements in the sql database, so i didnt have to bother with future powerbi issues next time they update.

 

 

v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

I guess you get data from SQL database, right? 

 

When get data from SQL database, if conditions can't be more than 10 levels. If you enter data not get data from the SQL database, you can see you can add more than 10 levels conditions. 

 

This is a limitation just as the error points out: 

 

q2.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have the same problem myself, and this conditional column came with the december update of powerbi desktop, i had no problem with earlier versions of powerbi desktop and this nesting.

 

the nesting is done in powerbi desktop after import

Hi @coiter,

 

Did you get data from SQL database as well? Please make sure the condition level less than 10. 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, i got the data from SQL database as imported data.

 

and i run this Nested IF as a conditional column inside Powerbi, and have been running this for over 6 months without any problems. So saying its SQL that is the problem doesnt make any logical sense, when it happens after upgrading to PowerBI December update.

 

so what changed from November to December to make this a problem, because my sql server is the same as before.

Anonymous
Not applicable

The error I get is 

 

    Message=Case expressions may only be nested to level 10.

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.