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
strikenoir
New Member

Cumulative Sales Subtotaling Column by Day over a Week

Hi,

 

Relatively new to Power BI and using DAX, but I've so far accomplished being able to produce everything I wanted to. There is however, one component to the report I am trying to build that is a business requirement towards it.

 

This is a simple report that is intended to run daily to gives sales and other metrics by day of the week for a given week. While it can return a grand total at the very far right giving the sum of everything, I want to somehow include (somewhere) a section that gives the cumulative total for only the days that have past in the week.

 

See image below for example of the standard Excel version of how we produce the report now.

 

 

2017-09-26_1411.pngI figure a standard matrix in BI is not really able to fully accomplish this, so I don't know how simply or easy it is to achieve this, if at all. If curious why this cumulative total is needed, the sales are also compared against the previous year, so the grand total at the far right would compare only days that have past versus all of last year - not realistic from a business perspective; removing the previous data from days that have yet to come is also not a viable solutions as it is preferred to see the figures still as future comparables.

 

I appreciate any help, feedback or alternatives that can be provided.

 

Thanks,

Johnson 

 

1 ACCEPTED SOLUTION
v-caliao-msft
Employee
Employee

@strikenoir,

 

Based on your description, you need a function to return week to date value. Currently, there is not such a function that return WTD directly. We can use this DAX expression instead.

Sales-CWeek =
CALCULATE (
    [SalesTotal],
    FILTER (
        'PeriodDate',
        YEAR ( 'PeriodDate'[Date] ) = YEAR ( NOW () )
            && WEEKNUM ( 'PeriodDate'[Date], 2 ) = WEEKNUM ( NOW (), 2 )
    )
)

 And then for last year, you could use this function

Sales-CWeek =
CALCULATE (
    [SalesTotal],
    FILTER (
        'PeriodDate',
        YEAR ( 'PeriodDate'[Date] ) = YEAR ( NOW ()-1 )
            && WEEKNUM ( 'PeriodDate'[Date], 2 ) = WEEKNUM ( NOW (), 2 )
    )
)

 

Regards,

Charlie Liao

View solution in original post

1 REPLY 1
v-caliao-msft
Employee
Employee

@strikenoir,

 

Based on your description, you need a function to return week to date value. Currently, there is not such a function that return WTD directly. We can use this DAX expression instead.

Sales-CWeek =
CALCULATE (
    [SalesTotal],
    FILTER (
        'PeriodDate',
        YEAR ( 'PeriodDate'[Date] ) = YEAR ( NOW () )
            && WEEKNUM ( 'PeriodDate'[Date], 2 ) = WEEKNUM ( NOW (), 2 )
    )
)

 And then for last year, you could use this function

Sales-CWeek =
CALCULATE (
    [SalesTotal],
    FILTER (
        'PeriodDate',
        YEAR ( 'PeriodDate'[Date] ) = YEAR ( NOW ()-1 )
            && WEEKNUM ( 'PeriodDate'[Date], 2 ) = WEEKNUM ( NOW (), 2 )
    )
)

 

Regards,

Charlie Liao

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.