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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
cottrera
Post Prodigy
Post Prodigy

Create order list

Hi 

 

I have a table with many rows of repairs our complany has completed, depending on the age of the job a age distribution is added. However the order of the age distribution is not correct. I need to add a new column with a multiple  if statement to say if ="0-4" , then 1, IF ="5-9", then 2, IF = "10-14", then 3    

and so on. I have shown the order I would like

 

 

OrderWorkingDaysToCompBuckets
10-4
25-9
310-14
415-19
520-24
625-29
730-34
835-39
940-44
1045-49
1150-54
1255-59
1360-64
1465-69
1570-74
1675-79
17>=80

 

Thank you

Richard

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@cottrera 

 

Instead of multiple if statements try this approach.

See attached file as well

First extract the ending range value using

 

EndingRange =
VAR pos1 =
    SEARCH ( "-", [WorkingDaysToCompBuckets], 1, 0 )
VAR pos2 =
    IF ( pos1 = 0, SEARCH ( "=", [WorkingDaysToCompBuckets], 1, 0 ), pos1 )
RETURN
    VALUE (
        RIGHT ( [WorkingDaysToCompBuckets], LEN ( [WorkingDaysToCompBuckets] ) - pos2 )
    )

Then we can RANK this column

 

RANK = RANKX(Table1,[EndingRange],,ASC,Dense)

 

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@cottrera 

 

Instead of multiple if statements try this approach.

See attached file as well

First extract the ending range value using

 

EndingRange =
VAR pos1 =
    SEARCH ( "-", [WorkingDaysToCompBuckets], 1, 0 )
VAR pos2 =
    IF ( pos1 = 0, SEARCH ( "=", [WorkingDaysToCompBuckets], 1, 0 ), pos1 )
RETURN
    VALUE (
        RIGHT ( [WorkingDaysToCompBuckets], LEN ( [WorkingDaysToCompBuckets] ) - pos2 )
    )

Then we can RANK this column

 

RANK = RANKX(Table1,[EndingRange],,ASC,Dense)

 

Thank you this works fine

 

Richard

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.