Forum Discussion
hitesh1607
Advocate II
5 years agoDAX 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...
- 5 years ago
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
AlB
Community Champion
5 years agoHi hitesh1607
Measure =
CALCULATE (
SUM ( Sales[Gross Price] ),
YEAR ( Sales[ShipDateKey] ) = 2021,
MONTH ( Sales[ShipDateKey] ) = 1,
YEAR ( Sales[OrderDate] ) = 2020,
MONTH ( Sales[OrderDate] ) = 12
)
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
hitesh1607
Advocate II
5 years agoHi AlB - This way my DAX will become static and I need a dynamic solution that can determine the Current Month for the Ship date and the previous month for the Order Date. Is there a way we can write a DAX using relative Calendar month ?? I Do have that in my dimCalendar and it changes dynamically.