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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Calculate day by day acumulated by week or WTD

Hello,

 

 

Its been really difficult to find and understand how is calculated a WTD measure.

 

What i just really want is to have a formular that gives the total of the transactions within the same week, totalizing what you sold from monday to sunday and reset the value to zero at the beginning of each week.



 

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

try this.

 

 

Total Sales WTD =
CALCULATE (
    [Total Sales];
    FILTER (
        ALL ( 'Calendar' );
        'Calendar'[Year] = MAX ( 'Calendar'[Year] )
            && 'Calendar'[Week] = MAX ( 'Calendar'[Week] )
            && 'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    )
)

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

7 REPLIES 7
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

To achieve the running total by week, you need a week No. column in the table. If possible, could you please share some sample data for further test?

 

Regards,

Jimmy Tao

Anonymous
Not applicable

Here's the pbi file

 

https://1drv.ms/u/s!Ag7DnkvMsR95qwP-d0tWSHCdcej0?e=RiplD5

 

@v-yuta-msft 

Can you help me out plis?

mwegener
Most Valuable Professional
Most Valuable Professional

Gi @Anonymous ,

are you searching for this?

 

 

Total Sales WTD =
CALCULATE (
    [Total Sales];
    FILTER (
        ALL ( 'Calendar' );
        'Calendar'[Week] = MAX ( 'Calendar'[Week] )
            && 'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    )
)

 


 If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Anonymous
Not applicable

Hey @mwegener  Thanks a lot, it is almost the result im looking for, something i notice is that it acumulated the amount sold for the previous years the same date, and what i need is to reset the value at the end of every year

So, if i put the measure in a calendar table showing from year to day on the aggregation level,  the 1st week of 2019 value returned is the sum of the sales of the 1st week from 2017 to 2019

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

try this.

 

 

Total Sales WTD =
CALCULATE (
    [Total Sales];
    FILTER (
        ALL ( 'Calendar' );
        'Calendar'[Year] = MAX ( 'Calendar'[Year] )
            && 'Calendar'[Week] = MAX ( 'Calendar'[Week] )
            && 'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    )
)

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

look at this.

https://docs.microsoft.com/en-us/dax/weeknum-function-dax

 

 

Date = 
ADDCOLUMNS (
	CALENDARAUTO( ), 
    "Year", YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Number", MONTH ( [Date] ),
    "Weekday", FORMAT ( [Date], "dddd" ),
    "Weekday number", WEEKDAY( [Date] ),
	"Week", WEEKNUM ( [Date], 2),
    "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1,
    "Day of Month", Day([Date])
)

 

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous 

 

look at this.

 

https://www.sqlbi.com/articles/week-based-time-intelligence-in-dax/

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.