Forum Discussion
Anonymous
2 years agoNot applicable
Last 4 weeks sales from specific date
Hi All, I have been searching for a while and while things are close and I have tried to manipulate the dax, it's not coming out. Creating this column. I used this link as reference: Need hel...
Anonymous
2 years agoNot applicable
Hi Anonymous ,
I see that lbendlin asks you for more details as well as Ashish_Mathur provides a formula.
I have create a simple sample, you can also refer to .
Create 2 measures.
RelWeekIndexmeasure =
VAR _sel =
SELECTEDVALUE ( 'Table 2'[Date] )
VAR StartOfWeek =
MAX ( 'Table 2'[Date] ) - WEEKDAY ( MAX ( 'Table 2'[Date] ), 2 ) + 1
VAR StartOfCurrentWeek = StartOfWeek - 28
VAR _re =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
'Table'[date] >= StartOfCurrentWeek
&& 'Table'[date] <= StartOfWeek
)
)
RETURN
IF (
MAX ( 'Table'[date] ) >= StartOfCurrentWeek
&& MAX ( 'Table'[date] ) <= StartOfWeek,
_re,
BLANK ()
)
Measure = MAXX('Table',[RelWeekIndexmeasure])
Or you can put [measure2] into the card directly.
Measure2 =
VAR _sel =
SELECTEDVALUE ( 'Table 2'[Date] )
VAR StartOfWeek =
MAX ( 'Table 2'[Date] ) - WEEKDAY ( MAX ( 'Table 2'[Date] ), 2 ) + 1
VAR StartOfCurrentWeek = StartOfWeek - 28
VAR _re =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
'Table'[date] >= StartOfCurrentWeek
&& 'Table'[date] <= StartOfWeek
)
)
RETURN
_re
How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.