Forum Discussion

hitesh1607's avatar
hitesh1607
Icon for Advocate II rankAdvocate II
5 years ago
Solved

DAX for two Date Keys in one table

Hi - I do have a Power BI model with ShipDateKey (Active) and OrderDateKey (Inactive) for fct Sales joined with DimCalendar. I am looking for a DAX calculation that gives me SUM of GrossPrice where S...
  • AlB's avatar
    5 years ago

    hitesh1607 

    Measure =
    VAR Y1_ =    YEAR ( TODAY () )
    VAR M1_ =    MONTH ( TODAY () )
    VAR Y0_ =    YEAR ( EDATE ( TODAY (), -1 ) )
    VAR M0_ =    MONTH ( EDATE ( TODAY (), -1 ) )
    RETURN
        CALCULATE (
            SUM ( Sales[Gross Price] ),
            YEAR ( Sales[ShipDateKey] ) = Y1_,
            MONTH ( Sales[ShipDateKey] ) = M1_,
            YEAR ( Sales[OrderDate] ) = Y0_,
            MONTH ( Sales[OrderDate] ) = M0_
        )
    

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers