Week to date calculation

Hello everyone!

I am Matteo from Italy. I recently participated at Power BI Challenge 6 and I am happy of being part of this Forum.

Because of Power BI weaknesses about, I wanted to create on my own a formula to calculate week to date sales and then comparing the days when I sell more.

I saw the formula online and I wanted to recreate by myself.

Please comment: I would be very happy if you share your opinion about it.

Here there is a screenshot with the formula used.

Hi @Matteo-Italy. As with most things in Power BI, there are many ways to solve a problem. Here’s one:

Sales WTD = 
VAR _CurrentDate = SELECTEDVALUE( Dates[Date] ) 
VAR _CurrentWeekYear = SELECTEDVALUE( Dates[Week & Year] ) 

RETURN
CALCULATE(
    [Total Sales],
    FILTER(
        ALL( Dates ),
        Dates[Week & Year] = _CurrentWeekYear &&
        Dates[Date] <= _CurrentDate
    )
)

Hope this helps.
Greg

4 Likes

Thank you Greg.

This is what I wanted: create a discussion and see your version of WTD sales. I think that EDNA Forum is the right place to share comments and opinions about DAX and Power BI.

Hope to see others’ thought.
Matteo

Will be surprised if other solutions are offered after that…

Think there are only 2 choices to calculate WTD values, first you’ve demonstrated using the day of week attribute. Second using an attribute at a weekly granularity like @Greg did. I think that’s a wrap :wink: