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
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
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.