Forum Discussion

BChinya's avatar
BChinya
Frequent Visitor
3 years ago
Solved

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

 

 

Thanks

 

 

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

 
 
 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    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:

    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

3 Replies