Skip to main content
cancel
Showing results for 
Search instead 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

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
Europe Fabric Conference

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 Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.