Forum Discussion

cursty's avatar
cursty
Frequent Visitor
1 year ago
Solved

Calculations with virtual table

Hello everyone,   I am working with expenses dataset. This dataset contains 4 columns: the unique id, item id (which can appear multiple times in case few payments have been made for the same item)...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for the reply from lbendlin and Greg_Deckler, please allow me to provide another insight.
    Hi cursty ,

    Please try the following dax.

    Perc_Rank = 
    VAR _tb = CALCULATETABLE(SUMMARIZECOLUMNS('Expenses'[item_id],"Expense",[Expenses]),ALL())
    VAR _expenses = VALUE([Expenses])
    VAR _lower = IF(COUNTROWS(FILTER(_tb, [Expense]<_expenses))=BLANK(),0,COUNTROWS(FILTER(_tb, [Expense]<_expenses)))
    VAR _higher = IF(COUNTROWS(FILTER(_tb, [Expense]>_expenses))=BLANK(),0,COUNTROWS(FILTER(_tb, [Expense]>_expenses)))
    RETURN
    DIVIDE(_lower,_higher+_lower,0)


    The result is as follows, hopefully it will meet your needs.


    Please see the attached pbix for reference.

    Best Regards,
    Dengliang Li

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