Forum Discussion

MONA4980's avatar
MONA4980
Frequent Visitor
1 year ago
Solved

LAST MONTHS SALES

Hello, 

I am really new to Power BI and DAX. I am trying to get MOM data and have to first get my profit from last month. 

Before I throw it out there know that I have a table that uses the calendar table and I have to use DAX to create that relationship. that is the first part of the function. When I add the second part it does not return any values. the dispdate is a short date format.

No errors but no results either.

What am I getting wrong?

LAST MONTH PROFIT = CALCULATE(SUM('ORDERS'[PROFIT]),USERELATIONSHIP('Calendar'[Date],'ORDERS'[DISPDATE]), PARALLELPERIOD('ORDERS'[DISPDATE], -1, MONTH))

 

  • MONA4980 

     

    Hi, 

    1. Mark your calendar table as Date table. 
    2. Use time-based functions like 'PARALLELPERIOD' on your Calendar table.

     

    That said, update your Measure to, 

     

    LAST MONTH PROFIT =
    CALCULATE(
    SUM('ORDERS'[PROFIT]),
    USERELATIONSHIP('Calendar'[Date], 'ORDERS'[DISPDATE]),
    PARALLELPERIOD('Calendar'[Date], -1, MONTH)
    )

     

    Hope this works for you:) 

4 Replies