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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Calculating the total number of sales for that number week.

Hi.  

 

I am trying to calcuate from my daily sales total a weekly sales total correlating to the week number.

 

Example would be adding together all 7 entries 0-6 to provide the total for week 13 say in all week 13 entries for that year  I have attched a screen shot,  I am eventally going to use this data to compare WoW MoM YoY sales.   The data runs from 2017 and the formula shown doesnt work for what i require.  The week number is repetative so at the turn of teh year starts from 1 again.

 

Thanks in advance 

 

Screenshot 2019-12-10 at 10.16.25.png

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

In my opinion, I'd like to suggest you use year and weeknum and conditions to manually filter calculate record.

 

Weekly to date total =
CALCULATE (
    SUM ( TotalSales[Total] ),
    FILTER (
        ALL ( TotalSales ),
        YEAR ( [Date] ) = EARLIER ( TotalSales[Date] )
            && WEEKNUM ( [Date], 2 ) = WEEKNUM ( EARLIER ( TotalSales[Date] ), 2 )
            && [Date] <= EARLIER ( TotalSales[Date] )
    )
)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

In my opinion, I'd like to suggest you use year and weeknum and conditions to manually filter calculate record.

 

Weekly to date total =
CALCULATE (
    SUM ( TotalSales[Total] ),
    FILTER (
        ALL ( TotalSales ),
        YEAR ( [Date] ) = EARLIER ( TotalSales[Date] )
            && WEEKNUM ( [Date], 2 ) = WEEKNUM ( EARLIER ( TotalSales[Date] ), 2 )
            && [Date] <= EARLIER ( TotalSales[Date] )
    )
)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
JarroVGIT
Resident Rockstar
Resident Rockstar

Typically, these kind of calculations are done in a measure, but you are trying to do it in a calculated column. That is not a problem per se, it is just worth noting. What is weird though is that you are trying to add this to a calendar table. That just seems odd, unless there is a specific reason for doing so? Could you share a pbix file with you total data structure, (you can make it with dummy data if that helps)? 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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