cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Post Prodigy

## 2 calandar Week back

Hi All,

iam trying to get 2 calander week back (not 14 days)

this is my measure

``````SalesTwoWeeksAgo =
CALCULATE (
SUM ( 'Table'[SalesAmount] ),
FILTER (
ALL ( 'Table' ),
COUNTROWS (
FILTER (
'Table',
EARLIER ( 'Table'[Date] ) = DATEADD ( 'Table'[Date], -14, DAY )
)
)
)
)``````

Mark my post as a solution!

1 ACCEPTED SOLUTION
Community Support

Hi  @netanel ,

You can modify the DAX formula to the following:

``````Measure =
var _week=WEEKNUM(MAX('Table'[Date]),2)
var _lastweek=WEEKNUM(MAX('Table'[Date]),2)-1
var _nextweek=WEEKNUM(MAX('Table'[Date]),2)+1
var _mindate=
MINX(
FILTER(ALL('Table'),WEEKNUM('Table'[Date],2) = _lastweek),'Table'[Date])
var _maxdate=
MAXX(
FILTER(ALL('Table'),WEEKNUM('Table'[Date],2) = _nextweek),'Table'[Date])
return
CALCULATE (
SUM ( 'Table'[SalesAmount] ),
FILTER (
ALL ( 'Table' ),
COUNTROWS (
FILTER (
'Table',
'Table'[Date]>=_mindate&&'Table'[Date]<=_maxdate
)
)
)
)``````

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support

Hi  @netanel ,

You can modify the DAX formula to the following:

``````Measure =
var _week=WEEKNUM(MAX('Table'[Date]),2)
var _lastweek=WEEKNUM(MAX('Table'[Date]),2)-1
var _nextweek=WEEKNUM(MAX('Table'[Date]),2)+1
var _mindate=
MINX(
FILTER(ALL('Table'),WEEKNUM('Table'[Date],2) = _lastweek),'Table'[Date])
var _maxdate=
MAXX(
FILTER(ALL('Table'),WEEKNUM('Table'[Date],2) = _nextweek),'Table'[Date])
return
CALCULATE (
SUM ( 'Table'[SalesAmount] ),
FILTER (
ALL ( 'Table' ),
COUNTROWS (
FILTER (
'Table',
'Table'[Date]>=_mindate&&'Table'[Date]<=_maxdate
)
)
)
)``````

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors