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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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

 


 

3 REPLIES 3
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.