Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
netanel
Post Prodigy
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 )
            )
        )
    )
)







Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

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.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

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