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
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)

 


Regards
Zubair

Please try my custom visuals

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)

 


Regards
Zubair

Please try my custom visuals

Thank you this works fine

 

Richard

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.