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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
stino123
Helper II
Helper II

Previous year Week to date

Hey,

 

I am trying to create a week to date measure for previous year same day. Generally speaking my function (See below) works. But I do get blanks on random days. Would someone know why?

 

Function:

Net sales PWTD =
var __currentYear = SELECTEDVALUE( 'Calendar'[Year-Month Sort] )
    var __currentWeek = SELECTEDVALUE( 'Calendar'[ISO Week])
    var __lastDayNumberInWeek = MAX( 'Calendar'[Day of Week] )
    var __lastYear = __currentYear - 1
    var __prevWeek = __currentWeek
    var __output =
        CALCULATE(
           [Nett Sales],
            'Calendar'[Year-Month Sort] = __lastYear,
            'Calendar'[ISO Week] = __prevWeek,
            'Calendar'[Day of Week] <= __lastDayNumberInWeek,
            ALL( 'Calendar')
        )
    return
        __output
 
Result:
Screenshot 2022-09-06 121221.jpg
1 ACCEPTED SOLUTION
2 REPLIES 2
stino123
Helper II
Helper II

Hey @amitchandak the first blog post helped find my solution, thanks for this! Would you know why my dax resulted in blanks?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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