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

Dynamic grouping Power BI

Hi

 

I need to create a Clustered bar chart, that displays the total number of complaints received grouped by the difference between the production date of an item and the date in which I received the complain, so for example I have Item A and I need the number of complaints received based on the following groups 0-30 days, 31- 60 days, 61- 90 days and > 90 days, where the days represent the difference between the two dates mentioned before.

 

However I need this groups to be dynamic according to the item I select on a slicer, so for example Item A has the groups mentioned before, while Item B has groups as 0-15 days, 16-25 days, > 26 days, Item C 0 - 20 days, 21-30 days, 31-90 days > 90 days, and so on; therefore I also need that the final user is able to select the different ranges of days to create the different groups. Is there any way I can achieve this result.

 

Thank you so much

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

For the visual axis, it only supports columns, but columns cannot be generated dynamically by slicer. So there are two workarounds.

vxiaotang_0-1652927369479.png

(1) Create an auxiliary visual

vxiaotang_1-1652927531825.png

(2) use tooltip

vxiaotang_2-1652927562850.png

Here are all the measures used (just take product A as an example):

A Range = 
var _v1= [Slicer1 Value]
var _v2=[Slicer2 Value]
var _v3=[Slicer3 Value]
var _cur= MIN(Stage[Column1])
return 
SWITCH(TRUE(),
_cur="Stage 1","0-"&_v1&" days",
_cur="Stage 2",_v1&"-"&_v2&" days",
_cur="Stage 3",_v2&"-"&_v3&" days",
_cur="Stage 4",">"&_v3&" days")
A DaysPerComplain = 
var _Pd= CALCULATE(MAX('production date list'[production date]),'production date list'[Product]= MIN('Table'[Product]))
return DATEDIFF(_Pd,MIN('Table'[complain date]),DAY)
A Count = 
var _cur= MIN(Stage[Column1])
var _PName= "Product A"
return 
SWITCH(TRUE(),
_cur="Stage 1",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]<= [Slicer1 Value])),
_cur="Stage 2",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]> [Slicer1 Value] && [A DaysPerComplain]<= [Slicer2 Value])),
_cur="Stage 3",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]> [Slicer2 Value] && [A DaysPerComplain]<= [Slicer3 Value])),
_cur="Stage 4",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]> [Slicer3 Value])))

For more please see my sample file attached below.

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

For the visual axis, it only supports columns, but columns cannot be generated dynamically by slicer. So there are two workarounds.

vxiaotang_0-1652927369479.png

(1) Create an auxiliary visual

vxiaotang_1-1652927531825.png

(2) use tooltip

vxiaotang_2-1652927562850.png

Here are all the measures used (just take product A as an example):

A Range = 
var _v1= [Slicer1 Value]
var _v2=[Slicer2 Value]
var _v3=[Slicer3 Value]
var _cur= MIN(Stage[Column1])
return 
SWITCH(TRUE(),
_cur="Stage 1","0-"&_v1&" days",
_cur="Stage 2",_v1&"-"&_v2&" days",
_cur="Stage 3",_v2&"-"&_v3&" days",
_cur="Stage 4",">"&_v3&" days")
A DaysPerComplain = 
var _Pd= CALCULATE(MAX('production date list'[production date]),'production date list'[Product]= MIN('Table'[Product]))
return DATEDIFF(_Pd,MIN('Table'[complain date]),DAY)
A Count = 
var _cur= MIN(Stage[Column1])
var _PName= "Product A"
return 
SWITCH(TRUE(),
_cur="Stage 1",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]<= [Slicer1 Value])),
_cur="Stage 2",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]> [Slicer1 Value] && [A DaysPerComplain]<= [Slicer2 Value])),
_cur="Stage 3",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]> [Slicer2 Value] && [A DaysPerComplain]<= [Slicer3 Value])),
_cur="Stage 4",CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Product]=_PName&& [A DaysPerComplain]> [Slicer3 Value])))

For more please see my sample file attached below.

 

Best Regards,

Community Support Team _Tang

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

Anonymous
Not applicable

Hi v-xiotang, thank you so much for your reply, I solved this before using also the parameters as you but your solution helped me to improve what I had done before. Thanks a lot for your answer I really appreciate it.

amitchandak
Super User
Super User

@Anonymous , You to create a measure that displays these values. say at the customer, complaints level .

 

Have a table with all these values and join it back in measure using customer complaints  in summarize in a measure

 

Please check the code below, you need equal to and you need to summarize as you two columns not one.

 

if only complaints level can suffice you can use the values.

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Anonymous
Not applicable

Hi Amit

 

Thank you for your answer, however I would like to know if it's possibile to make the measure that you named "Margin Type" dynamic, in the sense that I need the limits of each group to change according to what the user selects in a slicer for the limits, this groups also change according to the product I filter. I attach an imagen to show you how it must work

 

MarcelaB_0-1651738652078.png

Then this will be visualized in a clustered br chart

 

MarcelaB_1-1651738706041.png

Thanks a lot 

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.