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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
xariet
Helper I
Helper I

Dynamic Segmentation

Hi All

I am struggling to correctly calculate bins_Segments.

I have an Annual Income table : 

Annual Income = GENERATESERIES(18000, 1560000,1000) and [Value1] is the column in this table with generated amounts.

And I have a parameter that regulates the size of the bins. So depending on which Bin size I choose the number of rows in the below visual changes. 

 

xariet_0-1684199459424.jpeg

I have also created a table param_Segment to be able to calculate the number of bins in each segment.

xariet_1-1684199866742.jpeg

My current Bins_segment calculation is: 

Bins_segments = CALCULATE(COUNTROWS(SUMMARIZE('Annual Income','Annual Income'[Value1])), FILTER('Annual Income', NOT(ISEMPTY(FILTER(param_Segment, NOT(ISBLANK('Annual Income'[Value1]))&& param_Segment[Min]<'Annual Income'[Value1]&& param_Segment[Max]>='Annual Income'[Value1])))))
So I am trying to calculate the number of rows in the visual, which changes depending on the chosen bin size.  But as you can see it calculates the number of rows in the Annual Income table as a whole but not in visual. How do I achieve the correct result? 

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @xariet ,

According to your description, I create a same sample and here's my solution, create a measure.

Bins_segments =
CALCULATE (
    COUNTROWS ( SUMMARIZE ( 'Annual Income', 'Annual Income'[Value1] ) ),
    FILTER (
        'Annual Income',
        MOD (
            'Annual Income'[Value1]
                - MINX ( ALL ( 'Annual Income' ), 'Annual Income'[Value1] ),
            SELECTEDVALUE ( 'Parameter'[What is bin size] )
        ) = 0
            && NOT (
                ISEMPTY (
                    FILTER (
                        param_Segment,
                        NOT ( ISBLANK ( 'Annual Income'[Value1] ) )
                            && param_Segment[Min] < 'Annual Income'[Value1]
                            && param_Segment[Max] >= 'Annual Income'[Value1]
                    )
                )
            )
    )
)

Get the correct result.

vyanjiangmsft_0-1684399229581.png

I attach my sample below for your reference.

 

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

Best regards,

Community Support Team_yanjiang

 

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @xariet ,

According to your description, I create a same sample and here's my solution, create a measure.

Bins_segments =
CALCULATE (
    COUNTROWS ( SUMMARIZE ( 'Annual Income', 'Annual Income'[Value1] ) ),
    FILTER (
        'Annual Income',
        MOD (
            'Annual Income'[Value1]
                - MINX ( ALL ( 'Annual Income' ), 'Annual Income'[Value1] ),
            SELECTEDVALUE ( 'Parameter'[What is bin size] )
        ) = 0
            && NOT (
                ISEMPTY (
                    FILTER (
                        param_Segment,
                        NOT ( ISBLANK ( 'Annual Income'[Value1] ) )
                            && param_Segment[Min] < 'Annual Income'[Value1]
                            && param_Segment[Max] >= 'Annual Income'[Value1]
                    )
                )
            )
    )
)

Get the correct result.

vyanjiangmsft_0-1684399229581.png

I attach my sample below for your reference.

 

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

Best regards,

Community Support Team_yanjiang

 

Ahmedx
Super User
Super User

Share sample pbix file to help you

I don't think I can attach the file to my post ..

amitchandak
Super User
Super User

@xariet , refer if my approach here can help

 

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


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

Thank you , do you by any chance know how to achieve this result?  To group all bins where the income is more than 200,000. The below visual was done in Tableau, I can't figure out if this possible in Power BI..

xariet_0-1684207012117.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors