Forum Discussion

powerbiAG's avatar
powerbiAG
Frequent Visitor
3 years ago
Solved

Calculation based on 2 measures across different months.

  Hi All, We have a scenario where we need to do a calculation based on 2 measures across different months. Let me explain with example..   We have a monthly Sales table which has Actual Sales d...
  • Jihwan_Kim's avatar
    3 years ago

    Hi,

    I do not know how your datamodel looks like, but I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

    It is for creating a measure.

     

     

     

     

    Projected sales: =
    VAR _latestmonthdate =
        CALCULATE ( MAX ( Sales[Date] ), ALL ( 'Calendar' ) )
    VAR _latestmonth =
        MAXX (
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _latestmonthdate ),
            'Calendar'[Month-Year]
        )
    VAR _latestmonthsales =
        CALCULATE (
            SUM ( Sales[Sales] ),
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Month-Year] = _latestmonth )
        )
    VAR _projectedbookings =
        MAX ( Projected[Projected bookings] )
    RETURN
        IF ( ISBLANK ( SUM ( Sales[Sales] ) ), _latestmonthsales * _projectedbookings )