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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bga1
Frequent Visitor

Stacked Column Chart with Aggregated Data

Hi!

I have two tables linked with the tblOrder_ID
tblOrder

ID
1
2
3

 

tblOrderTask

tblOrder_IDDeltaDays
1-4
10
15
24
20
32
32
36
38

 

It should consider the minium of DeltaDays for each order.
If the minimum DeltaDays is <0 then count the order to the blue group.
If the minimum DeltaDays is =0 then count the order to the dark blue group.
If the minimum DeltaDays is >0 then count the order to the orange group.

 

In the Stacked Column Chart it should show the Amount of orders for each group

 

Chart1.PNG

I think that I have to create some kind of measure but so far I was not successfull

 

Thank you very much for your help!

 
1 ACCEPTED SOLUTION

Hi @bga1 ,

 

Based on your data, I created below chart, hope that's what you want:

Stacked Column Chart with Aggregated Data.PNG

I created 4 measure:

Measure 6 = CALCULATE(MIN('Table (3)'[DeltaDays]),ALLEXCEPT('Table (3)','Table (3)'[tblOrder_ID]))

BLUE = CALCULATE(DISTINCTCOUNT('Table (3)'[tblOrder_ID]),FILTER('Table (3)',[Measure 6] < 0))

DARK BLUE = CALCULATE(DISTINCTCOUNT('Table (3)'[tblOrder_ID]),FILTER('Table (3)',[Measure 6] = 0))

ORANGE = CALCULATE(DISTINCTCOUNT('Table (3)'[tblOrder_ID]),FILTER('Table (3)',[Measure 6] > 0))

 

Please try.

Aiolos Zhao





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @bga1 ,

 

You can try this:

Create calculated column in tblOrderTask: 

Column = IF(tblOrderTask[DeltaDays] < 0 ; 0; IF(tblOrderTask[DeltaDays] = 0; 1; IF(tblOrderTask[DeltaDays] > 0; 2)))

 

Create 3 measures: 

Less = CALCULATE(COUNTROWS(tblOrderTask); tblOrderTask[Column] = 0)
Equal = CALCULATE(COUNTROWS(tblOrderTask); tblOrderTask[Column] = 1)
More = CALCULATE(COUNTROWS(tblOrderTask); tblOrderTask[Column] = 2)

 

Then put all 3 measures in Value of a Stacked Column Chart

2020-02-19 13_08_10-Window.png

 

Hope this helps!

 

Br, 

Adrian

Thanks @Anonymous !

Your post helped me a lot.

 

Ther's one more problem I think.

I have to know the amount of rows in the order table. If I count in tblOrderTask I think I get the amount of Tasks and not orders.

Less = CALCULATE(COUNTROWS(tblOrderTask); tblOrderTask[Column] = 0)

 

I tried It like that, but it only shows the total amount of rows in tblOrder

Less = CALCULATE(COUNTROWS(tblOrder); tblOrderTask[Column] = 0)

 

Any ideas?

Anonymous
Not applicable

@bga1 

 

Try changing the calculated colum to:

Column = CALCULATE(IF(MIN(tblOrderTask[DeltaDays]) < 0 ; 0; IF(MIN(tblOrderTask[DeltaDays]) = 0; 1; IF(MIN(tblOrderTask[DeltaDays]) > 0; 2))); ALLEXCEPT(tblOrderTask; tblOrderTask[tblOrder_ID]))

 

Then change the measures to distinctcount on the Order_ID: 

 

Less = CALCULATE(DISTINCTCOUNT(tblOrderTask[tblOrder_ID]); tblOrderTask[Column] = 0)

 

 

/Adrian

bga1
Frequent Visitor

So, for my example in the OP it should show 1/1/1 because ther's one order in each group.

Hi @bga1 ,

 

Based on your data, I created below chart, hope that's what you want:

Stacked Column Chart with Aggregated Data.PNG

I created 4 measure:

Measure 6 = CALCULATE(MIN('Table (3)'[DeltaDays]),ALLEXCEPT('Table (3)','Table (3)'[tblOrder_ID]))

BLUE = CALCULATE(DISTINCTCOUNT('Table (3)'[tblOrder_ID]),FILTER('Table (3)',[Measure 6] < 0))

DARK BLUE = CALCULATE(DISTINCTCOUNT('Table (3)'[tblOrder_ID]),FILTER('Table (3)',[Measure 6] = 0))

ORANGE = CALCULATE(DISTINCTCOUNT('Table (3)'[tblOrder_ID]),FILTER('Table (3)',[Measure 6] > 0))

 

Please try.

Aiolos Zhao





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@AiolosZhao 

Thank you so much for the support so far

I have one additional question:

 

Measure 6 = CALCULATE(MIN('Table (3)'[DeltaDays]),ALLEXCEPT('Table (3)','Table (3)'[tblOrder_ID]))

 

Lets assume we have another column [Status] in Table (3).

What do I have to change in this measure, when I want to only consider values for this measure that have [Status] 1 or 8?

 

Hi @bga1 ,

 

Please try below measure:

 

CALCULATE(MIN('Table (3)'[DeltaDays]),ALLEXCEPT('Table (3)','Table (3)'[tblOrder_ID]),OR(Status = 1,Status = 8))

 

Aiolos Zhao 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.