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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
akt
Frequent Visitor

Power Query Conditional Column with "Else If" is returning ()blanks

I have 2 conditional columns (HACORF="YES" or null and HORF="YES" or null) that appear to work correctly and are not mutually exclusive. I am trying to create another conditional column CLASS based off of these but it is not working as expected for the HACO value which should be true if HACORF="YES" and HORF=null. Here is my syntax and the counts of the new conditional variable CLASS that are not sorting quite right (ie. are blank instead of HACO). Any suggestions? I can't figure out why the "else" statement would produce blank categories and also why my "PENDING" category is not returning any values as there should be some, I think these are the rest of the counts in the blank column.

 

#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "CLASS",
each if [HORF]="YES" then "HO"
else if [HACORF]="YES" then "HACO"
else if [status]<>"Complete" then "PENDING"
else "CO")

akt_0-1710223986315.png

Thanks for your insights!

3 REPLIES 3
tharunkumarRTK
Super User
Super User

@akt 
can you provide the pbix file with sample data?

I am not sure that is feasible. It is a monstrous file (almost maxes out the 17000 column limit) and I don't know if sample data would be able to replicate the issue. But a few more details about the data that seem to be important in some way:

1. The HACORF cases that seem to be not sorting correctly for the CLASS condition all do have multiple rows of data in the dataset with a primary row containing all the variables used in my conditions and secondary(+) rows containing values for a very limited amount of variables (~20 or less) unrelated to any conditional coding. I tried a "de-duplicate" step to remove any secondary(+) rows since that data is not relevant at the moment but that did not affect the table showing the count of observations still "blank" for the CLASS variable.

2. However some of the HORF cases also have instances of multiple rows for an observation but they all did sort correctly by CLASS.

3. Some of the HACORF blanks should be CLASS=CO (ie. they are not all just CLASS=PENDING) but also seem to be an observation that has multiple rows.

4. No matter what combination of other variables I tried that should respond to resorting for the CLASS condition there is something unique about these observations and their unwillingness to be labeled.

Anonymous
Not applicable

Hi @akt 

Do you need to account for the case where both hacoft and horf are null in your code? Can you provide some sample data that will give you a better solution?

 

Best Regards!

Yolo Zhu

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.