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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
NT2510
Frequent Visitor

Create Bins/Groups by Selected Date Slicer

Hi, I have hierarchical date slicer that shows date as Year->Quarter->Month (Table1[Created Date]).

 

On X-axis, I have month count calculated as  'Table1[Created Date] - Date(2014,1,1). So, month count is 1,2,3...12,13,14...till current month. Now, based on the date selected in slicer, I want to generate different Month count bins on x-axis such that first bin always starts with month selected in the slicer and all other bins should show current month count + 12.

Here are some examples: 

 

Created DateBin1Bin2Bin3
2/1/20200-22-14.14-26.
4/1/20200-44-16.16-28.
7/1/20200-77-19.19-31


I was able to create bins using calculated column but they wont dynamically change based on the slicer selected date/month. 

 

Any help would be appreciated. Thanks

4 REPLIES 4
Greg_Deckler
Super User
Super User

@NT2510 You would have to create your bins as measures. Then you would most likely need to use the disconnected table trick in some fashion, not exactly clear on your requirements though. 

 

Sorry, having trouble following, can you post sample data as text and expected output?


Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I am newbie and not sure how to upload file directly.

Here is the expected output. Date filter can be selected for multiple dates but I want only MAX(Month(Created Date)) which will be used for 1st bin.

Currently I have hardcoded max value as "5" hence 1st bin starts with 5. My only problem is, how I can pass Max of Created Date to calculated column or measure. I tried selectedvalue but it does not pass Max value instead all values.

Is there any way I can get Max value to pass so that bins can dynamically created.

 

NT2510_1-1600044958111.png

 

Thanks

 

@NT2510 , You can upload to onedrive or drop box and share link

amitchandak
Super User
Super User

@NT2510 , Typically these bins are created on diff like

 

diff= Datediff(max([Created Date]) , seleteddate(Date[Date]), Day)

 

Now I can bin this measure. So I can get like 1,3 , 2-6 month etc and have count for that.

 

Something like this

Measure =
countx(filter(values(Table[Created_date]),diff <=max(Bin[Bin end]) && diff >=max(Bin[Bin start])),Table[ID])

 

or you need like

Measure =
var _1 = countx(filter(values(Table[Created_date]),diff <=max(Bin[Bin end]) && diff >=max(Bin[Bin start])),Table[ID])
return
Switch ( True (),
_ <=3 , "0-3",
_ <=5 , "3-4",
////And so on
)

 

So not able to get you when you want bin returned by measure.

 

Also refer these

https://www.daxpatterns.com/dynamic-segmentation/
https://www.daxpatterns.com/static-segmentation/
https://www.poweredsolutions.co/2020/01/11/dax-vs-power-query-static-segmentation-in-power-bi-dax-po...
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization

 

 

 

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors