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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mv2019
New Member

Date Filter with WTD, MTD, STD, YTD Calculations

Hello,

 

I am trying to calculate WTD, MTD, STD, YTD Sales using the following code: 

 

WTD Sales = if(LOOKUPVALUE(Dim_Day[Week Number],Dim_Day[Day],Sales[Week End Date])=lookupvalue(Dim_Day[Week Number],Dim_Day[day],today())-1,Sales[Total Sales],0)

 

I have sales data for the past 3 years. My years start and stop based on a customer calendar. Sales are only recorded only a weekly basis (Saturdays).

 

Data is recorded one week behind so that is why I indicated -1 after today(). This code was working fine a few days ago for WTD from last week but now it's not working at all. Not sure what happened. 

 

In addition, I want users to be able to navigate between weeks. That is, be able to see what WTD sales were depending on the week they choose. 

 

Can someone help with this? Let me know if you require more info in order to help.

 

Thank you in advance.

 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @mv2019 

Please check if below measure could help.If it is not your case,please share some sample data and expected output which would be helpful to provide an accurate solution.You can also upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

Reference post:https://community.powerbi.com/t5/Desktop/Relative-WTD-MTD-amp-YTD-values/td-p/209139

How to Get Your Question Answered Quickly

WTD :=
CALCULATE (
    SUM ( Table1[Sales] ),
    DATESINPERIOD (
        Table1[Date],
        LASTDATE ( Table1[Date] ),
        - WEEKDAY ( LASTDATE ( Table1[Date] ) ),
        DAY
    )
)

 Regards,

Community Support Team _ Cherie Chen
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
v-cherch-msft
Employee
Employee

Hi @mv2019 

Please check if below measure could help.If it is not your case,please share some sample data and expected output which would be helpful to provide an accurate solution.You can also upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

Reference post:https://community.powerbi.com/t5/Desktop/Relative-WTD-MTD-amp-YTD-values/td-p/209139

How to Get Your Question Answered Quickly

WTD :=
CALCULATE (
    SUM ( Table1[Sales] ),
    DATESINPERIOD (
        Table1[Date],
        LASTDATE ( Table1[Date] ),
        - WEEKDAY ( LASTDATE ( Table1[Date] ) ),
        DAY
    )
)

 Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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