Forum Discussion

jthomson's avatar
jthomson
Solution Sage
4 years ago
Solved

TOPN sort order with USERELATIONSHIP

Hi,   Banging my head against the wall trying to work out how to get this to work. This is the measure in question:       Top2% = var claims = CALCULATE(COUNTROWS(dcl),USERELATIONSHIP(DateTab...
  • v-chenwuz-msft's avatar
    4 years ago

    Hi jthomson ,

     

    You want to add Userelationship to sumofthat?

    If yes, please try add CALCULATETABLE() to the TOPN()'s table, second parameter.

     

    Top2% =
    VAR claims =
        CALCULATE(
            COUNTROWS( dcl ),
            USERELATIONSHIP ( DateTable[Date], dcl[Settled Date] )
        )
    VAR top2calc =
        CALCULATE(
            ROUNDDOWN( DIVIDE( claims, 50 ), 0 ),
            USERELATIONSHIP ( DateTable[Date], dcl[Settled Date] )
        )
    VAR sumofthat =
        SUMX(
            TOPN(
                2,
                CALCULATETABLE( 'dcl', USERELATIONSHIP ( DateTable[Date], dcl[Settled Date] ) ),
                [total incurred], DESC
            ),
            [total incurred]
        )
    RETURN
        DIVIDE( sumofthat, top2calc )
    

     

    If i misunderstood you, please share your pbix file without sensitive data and expect result.

    Pbix in the end you can refer.

    Best Regards

    Community Support Team _ chenwu zhu

     

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