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
thorpyuk
Helper III
Helper III

Change Cumulative values to daily

Hi all,

I have a chart displaying daily sales values for the current week split out by day, and another measure for 'last week to date' shown below which will calculate the cumulative sales for the previous week so that i can do a week-on-week var. The issue is that when i drag this onto my daily chart, it shows cumulative for the previous week (makes sense i know!), but i want to show the previous week split out by its daily actuals (EG not cumulative) if possible? Here's my measure for the previous week to date:

NetSalesIncLWTD =
VAR CurrentWeek = SELECTEDVALUE( 'db_v_BaseCalendar_TYLY'[WeekNo] )
VAR CurrentYear = SELECTEDVALUE( 'db_v_BaseCalendar_TYLY'[FinYear] )
VAR CurrentDay = Max ('db_v_BaseCalendar_TYLY'[DayNo] )
RETURN
CALCULATE( [NetSalesIncM],
FILTER( ALL( 'db_v_BaseCalendar_TYLY' ),
        'db_v_BaseCalendar_TYLY'[WeekNo] = CurrentWeek -1 && 'db_v_BaseCalendar_TYLY'[FinYear] = CurrentYear && 'db_v_BaseCalendar_TYLY'[DayNo] <= CurrentDay ))
 
Thanks in advance
1 ACCEPTED SOLUTION

Hi Rena, yes in the end i edited Amitchandak's code slightly to go 1 week back:

 

NetSalesIncLW = 
var _max = maxx(ALLSELECTED('db_v_BaseCalendar_TYLY'),'db_v_BaseCalendar_TYLY'[DateName])
return
CALCULATE(SUMX(db_v_SalesProduct, [NetSalesIncM]),FILTER(all('db_v_BaseCalendar_TYLY'),'db_v_BaseCalendar_TYLY'[WeekNo]=max('db_v_BaseCalendar_TYLY'[WeekNo])-1 && 'db_v_BaseCalendar_TYLY'[DateName]=max('db_v_BaseCalendar_TYLY'[DateName])))

 

Thanks 

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

Week Rank and Week number will along with date calendar.

Check WTD page

https://www.dropbox.com/s/d9898a48e76wmvl/sales_analytics_weekWise.pbix?dl=0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

 Amitchandak, i already have a week to date and last week to date - i want to show them differently in my chart though.

In this picture i am gettin the top version (cumulative), but i want the bottom version to show (daily):

Temp.jpg

Try like

WTD = 
var _max = maxx(ALLSELECTED('Date'),'Date'[Weekday])
return
CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Week Rank]=max('Date'[Week Rank]) && 'Date'[Weekday]=max('Date'[Weekday])))
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Nearly! It's worked for the current week, but i want the previous week. Here's my edited version of your code:

LW = 
var _max = maxx(ALLSELECTED('db_v_BaseCalendar_TYLY'),'db_v_BaseCalendar_TYLY'[DateName])
return
CALCULATE(SUM(db_v_SalesProduct[NetSales]),FILTER(all('db_v_BaseCalendar_TYLY'),'db_v_BaseCalendar_TYLY'[WeekID]=max('db_v_BaseCalendar_TYLY'[WeekID]) && 'db_v_BaseCalendar_TYLY'[DateName]=max('db_v_BaseCalendar_TYLY'[DateName])))

 

Hi @thorpyuk ,

So if you have gotten the solution? Is there anything else can help you for this thread?

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Rena, yes in the end i edited Amitchandak's code slightly to go 1 week back:

 

NetSalesIncLW = 
var _max = maxx(ALLSELECTED('db_v_BaseCalendar_TYLY'),'db_v_BaseCalendar_TYLY'[DateName])
return
CALCULATE(SUMX(db_v_SalesProduct, [NetSalesIncM]),FILTER(all('db_v_BaseCalendar_TYLY'),'db_v_BaseCalendar_TYLY'[WeekNo]=max('db_v_BaseCalendar_TYLY'[WeekNo])-1 && 'db_v_BaseCalendar_TYLY'[DateName]=max('db_v_BaseCalendar_TYLY'[DateName])))

 

Thanks 

Hi @thorpyuk ,

Thanks for your reply. I'm glad to hear that your problem has been resolved. Could you please mark helpful post as "Answered"? It will help the other members in community easy to find it when they face the similar problem with you. Thank you.

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.