Forum Discussion

lauriedata's avatar
lauriedata
Resolver I
8 months ago
Solved

rank() function not working as expected (NOT USING RANKX)

Hello.  Whether or not I include "DENSE" in the formula, the result is identical.  The rank() function is giving me ties with skips in the numbering.  The rank is based on the total value of reward W...
  • MarkLaf's avatar
    MarkLaf
    8 months ago

    Thanks for sharing the pbix as that makes it much easier to troubleshoot.

     

    The reason that the measure is not working in your pbix is because of the [Rank_TopN Reward Value] is not blank filter on the visual. This adds a value filter to the visual's SUMMARIZECOLUMNS, which does not interact well with the ADDCOLUMNS I had originally used. We can circumvent this issue if we use SUMMARIZECOLUMNS instead. This worked for me with the is not blank filter in your shared pbix.

     

     

    Rank_TopN Reward Value fixed = 
    VAR _topN = SELECTEDVALUE('TopN'[Top N])
    VAR _core = 
        SUMMARIZECOLUMNS( 
            v_flt_ci_cs_adjustment_rwd[Loyalty ID],
            ALLSELECTED( 
                v_flt_ci_cs_adjustment_rwd[Loyalty ID], 
                v_flt_ci_cs_adjustment_rwd[reward_issue_date] 
            ), 
            "@selectedSum", CALCULATE( SUM( v_flt_ci_cs_adjustment_rwd[sum_reward_value] ) )
        )
    VAR _rank = RANK( DENSE, _core, ORDERBY( [@selectedSum], DESC ) )
    RETURN
    IF( _rank > 0 && _rank <= _topN, _rank )