Forum Discussion
Cumulative total over 2 years
- 6 years ago
Hi pawelj795 ,
First, one step in the above formula was complicated by me. I have modified it. Please check:
YTD Revenues 5 = VAR LastYearFirstDate = IF ( SELECTEDVALUE ( 'Calendar'[Year] ) = BLANK (), DATE ( YEAR ( LASTDATE ( Invent_Trans[Date] ) ) - 1, 1, 1 ), DATE ( SELECTEDVALUE ( 'Calendar'[Year] ) - 1, 1, 1 ) -------------changed ) VAR CurrentDate = IF ( SELECTEDVALUE ( 'Calendar'[Year] ) = BLANK (), MAX ( DimDates[Date] ), CALCULATE ( MAX ( DimDates[Date] ), FILTER ( DimDates, DimDates[Year] = SELECTEDVALUE ( 'Calendar'[Year] ) ) ) ) RETURN CALCULATE ( SUM ( Invent_Trans[Inventory Value] ), FILTER ( ALLSELECTED ( DimDates ), DimDates[Date] >= LastYearFirstDate && DimDates[Date] <= CurrentDate ) )Then, you can create your YearWeek column like so:
YearWeek = CONCATENATE ( Invent_Trans[Year], CONCATENATE ( " ", FORMAT ( Invent_Trans[WeekNum], "00" ) ) )Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Icey
It's finally seems working 🙂
One question though, in my main date table I add column with combined year and week number.
y
How to sort them correctly?
Hi pawelj795 ,
First, one step in the above formula was complicated by me. I have modified it. Please check:
YTD Revenues 5 =
VAR LastYearFirstDate =
IF (
SELECTEDVALUE ( 'Calendar'[Year] ) = BLANK (),
DATE ( YEAR ( LASTDATE ( Invent_Trans[Date] ) ) - 1, 1, 1 ),
DATE ( SELECTEDVALUE ( 'Calendar'[Year] ) - 1, 1, 1 ) -------------changed
)
VAR CurrentDate =
IF (
SELECTEDVALUE ( 'Calendar'[Year] ) = BLANK (),
MAX ( DimDates[Date] ),
CALCULATE (
MAX ( DimDates[Date] ),
FILTER ( DimDates, DimDates[Year] = SELECTEDVALUE ( 'Calendar'[Year] ) )
)
)
RETURN
CALCULATE (
SUM ( Invent_Trans[Inventory Value] ),
FILTER (
ALLSELECTED ( DimDates ),
DimDates[Date] >= LastYearFirstDate
&& DimDates[Date] <= CurrentDate
)
)
Then, you can create your YearWeek column like so:
YearWeek =
CONCATENATE (
Invent_Trans[Year],
CONCATENATE ( " ", FORMAT ( Invent_Trans[WeekNum], "00" ) )
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- pawelj7956 years ago
Post Prodigy
That work's perfectly!
Thanks - pawelj7956 years ago
Post Prodigy
HI Icey
I need to dig up my topic.
Currently, I'm updating this report and I need to add slicer with quarters and week numbers, but it require some modification to your measure.
In current conditions, I can only add slicer with year from table "Calendar".
Can you help me?