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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
prattja9
Frequent Visitor

Create User Defined Bin Slicer with Parameter

I have some data that looks like this: 

 

Employee IDAge (years)
1100
21
318
421
565
67
712
818
924
1036

 

I am trying to create a histogram that shows this data, with a slicer that will allow my users to define the size of the bins that are present in the visual. 

 

There is a blog post that many people have pointed to that solves this problem. I am trying to follow this method exactly, but the slicer it creates is not interacting with my visual. Does this method still work after the recent updates to the 'New Parameter' Menu?:
https://radacad.com/dynamic-banding-or-grouping-in-power-bi-using-dax-measures-choose-the-size-of-bi...

2 ACCEPTED SOLUTIONS
grantsamborn
Solution Sage
Solution Sage

Hi @prattja9

 

With the new New Parameters menu, select Numeric Range.  It works with the link you supplied. (pbix: 2 - Choose SIZE of Bins.pbix)

 

Let me know if you have any questions.

 

pbix: prattja9.pbix

View solution in original post

Does this help?  I changed  to COUNTROWS( DimCustomer ) to 

DISTINCTCOUNT( 'DimCustomer'[Employee ID] ) in the RETURN.
 
Count of Customers in each Band - by size - 2 = 
VAR _minAge = [Min Age]
VAR _maxAge = [Max Age]
VAR _bandSize = [What is Band Size Value]
VAR _AgeBandTable =
    GENERATESERIES(
        _minAge,
        _maxAge,
        _bandSize
    )
VAR _currAge = SELECTEDVALUE( 'Age Band'[Age] )
VAR _bandHead =
    MAXX(
        FILTER(
            _AgeBandTable,
            [Value] <= _currAge
        ),
        [Value]
    )
VAR _bandTail = _bandHead + _bandSize
RETURN
    IF(
        _currAge = _bandHead,
        CALCULATE(
            DISTINCTCOUNT( 'DimCustomer'[Employee ID] ),
            'Age Band'[Age] >= _bandHead
                && 'Age Band'[Age] < _bandTail
        )
    )

 pbix: prattja9.pbix

 

View solution in original post

5 REPLIES 5
grantsamborn
Solution Sage
Solution Sage

Hi @prattja9

 

With the new New Parameters menu, select Numeric Range.  It works with the link you supplied. (pbix: 2 - Choose SIZE of Bins.pbix)

 

Let me know if you have any questions.

 

pbix: prattja9.pbix

Interesting, I got it to work with the sample BI report. Another question, my actual data set has multiple line items for each employee. Is there a way to modify the 15th line in the "Count of Customers in each Band - by size" measure to accomodate that complication?

Does this help?  I changed  to COUNTROWS( DimCustomer ) to 

DISTINCTCOUNT( 'DimCustomer'[Employee ID] ) in the RETURN.
 
Count of Customers in each Band - by size - 2 = 
VAR _minAge = [Min Age]
VAR _maxAge = [Max Age]
VAR _bandSize = [What is Band Size Value]
VAR _AgeBandTable =
    GENERATESERIES(
        _minAge,
        _maxAge,
        _bandSize
    )
VAR _currAge = SELECTEDVALUE( 'Age Band'[Age] )
VAR _bandHead =
    MAXX(
        FILTER(
            _AgeBandTable,
            [Value] <= _currAge
        ),
        [Value]
    )
VAR _bandTail = _bandHead + _bandSize
RETURN
    IF(
        _currAge = _bandHead,
        CALCULATE(
            DISTINCTCOUNT( 'DimCustomer'[Employee ID] ),
            'Age Band'[Age] >= _bandHead
                && 'Age Band'[Age] < _bandTail
        )
    )

 pbix: prattja9.pbix

 

Got it to work using CALCULATE(DISTINCTCOUNT( instead of CALCULATE(COUTROWS(. 

 

Thanks for your help!

Sorry.  I didn't see this post until I posted.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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