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
bdehning
Post Prodigy
Post Prodigy

Conditional Column Question

Let me try this question another way.    I have the following Conditional Column that works for Numerical sorting. How can I add an Else if to continue from 5-50 without having to create 46 more Else If?     

 

 

Tenure2.PNG

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @bdehning ,

According to your description, here's my solution.

Add a custom column in Power Query.

vkalyjmsft_0-1666679366281.png

if [LOE By Year]=null then "No Data" else if[LOE By Year]<1 then "< 1 yr"else if [LOE By Year]<2 then "1 yr" else Text.Combine({Number.ToText(Number.RoundDown([LOE By Year]))," yrs"})

Result:

vkalyjmsft_1-1666679859856.png

Then in Desktop, select the LOE Range column, click Column tools>Sort by column>LOE By Year.

vkalyjmsft_3-1666680081808.png

Get the expected result:

vkalyjmsft_4-1666680177744.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

10 REPLIES 10
v-yanjiang-msft
Community Support
Community Support

Hi @bdehning ,

According to your description, here's my solution.

Add a custom column in Power Query.

vkalyjmsft_0-1666679366281.png

if [LOE By Year]=null then "No Data" else if[LOE By Year]<1 then "< 1 yr"else if [LOE By Year]<2 then "1 yr" else Text.Combine({Number.ToText(Number.RoundDown([LOE By Year]))," yrs"})

Result:

vkalyjmsft_1-1666679859856.png

Then in Desktop, select the LOE Range column, click Column tools>Sort by column>LOE By Year.

vkalyjmsft_3-1666680081808.png

Get the expected result:

vkalyjmsft_4-1666680177744.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

bdehning
Post Prodigy
Post Prodigy

 If a person had need for a smaller conditiotnal column, how do make No Data or Null stay ahead of <1 yr  when sorting?

That's where the SortOrder column comes in.  In the Data view, select the description and use Sort By Column to sort by the SortOrder column.

bdehning
Post Prodigy
Post Prodigy

But I want to see if they do exist in data 6 yrs, 7 yrs, 8, yrs, 9 yrs, etc?

If you want 50 buckets, you will probably need 50 lines of conditions unless you create a bucket table with the 50 buckets as well as upper and lower boundaries and a sort order column.

Ok the  Bucket Example is probably the best route and cleanest reather than 50 or more Else If's.  

bdehning
Post Prodigy
Post Prodigy

What do I use as Output if:   Else if LOE by Year is less than 51 Then ????

I'm guessing "5-50" based on your initial post.

grantsamborn
Solution Sage
Solution Sage

Just add 1 more Else-IF to check if LOE By Year is less than 51.

bdehning
Post Prodigy
Post Prodigy

I have a Decimal Number Column that provides Years Employed.   I use that to create the range of years.    

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors