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
Anonymous
Not applicable

How can I organizing stacked column chart in specific order?

Currently, my stacked column chart is visually organized from highest quantity to lowest quantity. I want it to be organized in a specific way. I want it to show: "Past due", Nov 2020, Dec 2020, Jan 2021, Feb 2021, Mar 2021, April 2021, "Future due". I tried creating a measure for each bucket, but it does not work in my case because there are new months being added and old months grouping in the "Past Due" bucket.

I tried sorting by a new column I created that shows order of the data using dates and that leads to a "Something went wrong error". 

I would really appreciate the help. Currently this is how Power BI has visualized the data. 

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

Hi @Anonymous ,

 

You want to sort your x-axis by "Past due", Nov 2020, Dec 2020, Jan 2021, Feb 2021, Mar 2021, April 2021, "Future due", am I right?

 

You can create a new sort table by the following measure:

 

 

 

Table 2 = ADDCOLUMNS(VALUES('Table'[ORDERING]),"forder",FIRSTNONBLANK('Table'[DUE_DATE],1))

 

 

 

Capture.PNG

Then you can sort the ordering column by forder column. At last, you can create a one to many relationship between sort table and data table by ordering column:

 

Capture1.PNG 

 

Use column in sort table as x-axis, it will show the order you expected.

 

Capture2.PNG

For more details, please refer to https://radacad.com/sort-a-column-with-a-custom-order-in-power-bi

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

4 REPLIES 4
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You want to sort your x-axis by "Past due", Nov 2020, Dec 2020, Jan 2021, Feb 2021, Mar 2021, April 2021, "Future due", am I right?

 

You can create a new sort table by the following measure:

 

 

 

Table 2 = ADDCOLUMNS(VALUES('Table'[ORDERING]),"forder",FIRSTNONBLANK('Table'[DUE_DATE],1))

 

 

 

Capture.PNG

Then you can sort the ordering column by forder column. At last, you can create a one to many relationship between sort table and data table by ordering column:

 

Capture1.PNG 

 

Use column in sort table as x-axis, it will show the order you expected.

 

Capture2.PNG

For more details, please refer to https://radacad.com/sort-a-column-with-a-custom-order-in-power-bi

 

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

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Hi@v-deddai1-msft ,

The Measure you created was not working for me. I have created a table below for sample of columns that might help us work this out. My goal is to replicate the "Ordering" column in the specific order it showing. We can use count of  "Buckets" for the y-axis.

Table1:

BUCKETORDERINGDUE_DATE
Past DuePast Due7/31/2020
Past DuePast Due10/31/2020
Past DuePast Due12/31/2019
11/1/2020Nov 2011/30/2020
11/1/2020Nov 2011/30/2020
11/1/2020Nov 2011/30/2020
12/1/2020Dec 2012/30/2020
12/1/2020Dec 2012/30/2020
12/1/2020Dec 2012/30/2020
1/1/2021Jan 211/15/2021
2/1/2021Feb 212/15/2021
3/1/2021Mar 213/15/2021
4/1/2021Apr 214/15/2021
More than 9 months aheadMore than 9 months aheaddateadd(due_date,6,month)
   
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

What's you expected x-axis like? You can create a new table for x-axis:

 

 

Units =
UNION ( { "Past due" }, VALUES ( Table1[Unit] ), { "Future due" } )

 

 

Then you can use the following measure for your stacked column chart:

 

Measure =
SWITCH (
    SELECTEDVALUE ( Units[Value] ),
    "Past Due",
        CALCULATE (
            SUM ( Table[amount] ),
            FILTER (
                Table,
                Table[Date] < DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
            )
        ),
    "Future due",
        CALCULATE (
            SUM ( Table[amount] ),
            FILTER ( Table, Table[Date] > DATE ( 2021, 4, 30 ) )
        ),
    CALCULATE (
        SUM ( Table[amount] ),
        FILTER ( Table, TREATAS ( VALUES ( Units[Value] ), Table[Date] ) )
    )
)

 

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

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

This is what this visual currently looks like. 

Stacked Chart.PNG

 

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.