Forum Discussion

msuser48's avatar
msuser48
Helper I
3 years ago
Solved

Count rows dynamically and aggregate

This post almost explains perfectly what I want: https://community.powerbi.com/t5/Desktop/Dynamic-Count-of-Rows/m-p/662950   The code proposed by parry2k in the post also works: Count of Products ...
  • v-yalanwu-msft's avatar
    3 years ago

    Hi, msuser48 ;

    Try it.

    Count of Products = 
    VAR __currentProduct = SELECTEDVALUE( Table3[Product] ) 
    RETURN 
    IF(HASONEVALUE(Table3[Product]),
    CALCULATE( 
        COUNTROWS( Table3 ),  
        ALLSELECTED( Table3 ), 
        Table3[Product] <= __currentProduct 
    ),COUNTROWS('Table3'))

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.