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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Gopal_PV
Helper III
Helper III

How sort Switch column values with other order column in power bi

Hi Friends,

I have imported snowflake view in to Power bi. Now I have created new column using switch for Bucket list of units. Now i want to  order the same bucket list. I want to use same bucket for slicer.
DIY, Small,Medium, Enterprise,DG Enterprise. I Want this same order for slicer.

Units_Bucket =
SWITCH(
    TRUE(),
    -- Non-DG buckets
    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] < 25, "DIY",

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] <= 50, "Small",

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] <= 300, "Medium",

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] <= 1000, "Large",

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] > 1000, "Enterprise",

    -- PMI special case
    'Unit'[Parent_Name] = "DG" &&
    'Unit'[PERIOD_UNITS] > 1000, "PMDGIDG Enterprise",

    -- Everything else DG (≤1000) → excluded
    "Excluded"
)

--------------

Units_Bucket_Order =
SWITCH(
    TRUE(),
    'Unit'[Units_Bucket] = "DIY", 1,
    'Unit'[Units_Bucket] = "Small", 2,
    'Unit'[Units_Bucket] = "Medium", 3,
    'Unit'[Units_Bucket] = "Large", 4,
    'Unit'[Units_Bucket] = "Enterprise", 5,
    'Unit'[Units_Bucket] = "DG Enterprise", 6,
    'Unit'[Units_Bucket] = "Excluded", 7
)
Now i am triying to sort Units_bucket  by Bucker Order.
Facing below error. Can you please help me in this.
Gopal_PV_1-1755618288126.png

 


 

5 REPLIES 5
v-prasare
Community Support
Community Support

Hi @Gopal_PV,

We would like to confirm if our community members answer resolves your query or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are happy to help you.

 

@Shahid12523@srlabhe & @FBergamaschi  thanks for your prompt response.

 

 

Thank you for your patience and look forward to hearing from you.
Best Regards,
Prashanth Are

Shahid12523
Power Participant
Power Participant

- Create a lookup table with unique bucket names and order:
- DIY → 1
- Small → 2
- Medium → 3
- Enterprise → 4
- DG Enterprise → 5


- Fix naming in your SWITCH logic so it matches the lookup table exactly.


- Sort the lookup table’s Units_Bucket column by Bucket_Order.


- Use the lookup table’s Units_Bucket in your slicer for correct order and clean filtering.


Let me know if you want a one-table workaround or multilingual slicer support too.

Shahed Shaikh
srlabhe
Helper III
Helper III

Hi Add the belwo as different dataset in Power BI report

BucketID
DIY1
Small2
Medium3
Large4
Enterprise5
DG Enterprise6
Excluded7

 Then join the Bucket with your main data , 

Goto Data Tab

Click on Newly added dataset 

Click on BUcket Column->Sort based on ID

 

 

FBergamaschi
Solution Sage
Solution Sage

Without sample data, I can only suggest ot rewrite the column

Units_Bucket_Order =

SWITCH(
    TRUE(),
    -- Non-DG buckets
    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] < 251,

 

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] <= 50, 2,

 

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] <= 300, 3,

 

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] <= 1000, 4,

 

    'Unit'[Parent_Name] <> "DG" &&
    'Unit'[PERIOD_UNITS] > 1000, 5,

 

    -- PMI special case
    'Unit'[Parent_Name] = "DG" &&
    'Unit'[PERIOD_UNITS] > 1000, 6,

 

    -- Everything else DG (≤1000) → excluded
    7
)
 
And try again the sorting, if it does not work, please upload the pbix in a cloud service and share here the link so I can inspect it and fix
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi .

Now i am facing cercular depency error. Please find the pbix file in the attachment.

Gopal_PV_0-1755692205370.png

 

 

Thank you 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.