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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.