Forum Discussion

cerebro's avatar
cerebro
Icon for Helper I rankHelper I
1 year ago
Solved

Address "previous" column value for measures

Dear community,   i would like to see the change in customer margins from month to month in a measure with the help of month number.  The data is on a daily basis, previous month functions do not ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi cerebro ,

     

    Do you want to display Revenue per customer on a monthly basis and show the growth rate compared to the previous month?

     

    Here is my test and attached pbix file for your reference.

    Margin = VAR currentMonth = MONTH(MAX('Table'[Date]))
    VAR lastMonth = currentMonth-1
    VAR cust = MAX('Table'[Customer])
    VAR lastRev = CALCULATE(SUM('Table'[Revenue]),ALL('Table'),MONTH('Table'[Date])=lastMonth&&'Table'[Customer]=cust)
    RETURN IF(CONTAINS(ADDCOLUMNS(ALL('Table'[Date]),"Month",MONTH('Table'[Date])),[Month],lastMonth),(SUM('Table'[Revenue])-lastRev)/lastRev)

    The conditional formatting.

     

     

    Best regards,

    Mengmeng Li