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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
BChinya
Frequent Visitor

Sumx is not working with iterative condition

Hi,

Problem statement trying to address : I have a dataset that have people and ther age. I am trying to count the number of people based on the dynamic bin(X axis) that i have created using numeric range filter from 0 - 120 .  But for some reason my measure (SumX )is not working,  it is just putting all the counts into one single bucket. Please see the screenshot and measure below, Can someone please assist. Thanks!

 

Expected result is to show 1 in each 60 and 70 row's, but it is showing in in single bucket i.e. 60.

 

Number of subjects within =
var _Binsize_min = SELECTEDVALUE('Bin Start'[Bin Start])
var _binsize_end = _Binsize_min + 'Bin Size'[Bin Size Value]

 

var _subnr =
       SUMX(ALLSELECTED(DM[Subject]),IF(MIN(DM[Age])>=_Binsize_min && MIN(DM[Age])< _binsize_end,1,0))
                        return _subnr

 

Capture.PNG

 

Thanks

 

 

**************************************

 
 
 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BChinya ,

Please try:

Number of subjects within = 
VAR _Binsize_min =
    SELECTEDVALUE ( 'Bin Start'[Bin Start] )
VAR _binsize_end =
    _Binsize_min + SELECTEDVALUE ( 'Bin Size'[Bin Size] )
VAR _subnr =
    CALCULATE (
        COUNTROWS ( DM ),
        'DM'[Age] >= _Binsize_min
            && 'DM'[Age] < _binsize_end,
        ALLSELECTED ( 'DM'[Subject] )
    )
RETURN
    _subnr

Output:

vcgaomsft_0-1694573569411.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @BChinya ,

Please try:

Number of subjects within = 
VAR _Binsize_min =
    SELECTEDVALUE ( 'Bin Start'[Bin Start] )
VAR _binsize_end =
    _Binsize_min + SELECTEDVALUE ( 'Bin Size'[Bin Size] )
VAR _subnr =
    CALCULATE (
        COUNTROWS ( DM ),
        'DM'[Age] >= _Binsize_min
            && 'DM'[Age] < _binsize_end,
        ALLSELECTED ( 'DM'[Subject] )
    )
RETURN
    _subnr

Output:

vcgaomsft_0-1694573569411.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you. This works like charm!

Ritaf1983
Super User
Super User

Hi @BChinya 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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.