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
cham
Post Patron
Post Patron

Previous week sales caluculation

HI @Anonymous 

 

I want to get the previous week sales amount and get the difference between this week sales and previous week sales. How can i get that?

 

Regards,

Cham

2 REPLIES 2
Anonymous
Not applicable

Hi @cham  , 

 

First you need to have a table with a calendar. 

 

table = Calendar (dateStart;dateEnd)

After creat new column

WeekNum = WEEKNUM('calendar'[Date];2) 
where 2 -start week on Monday

Create relationsship you table "Fact" with table "Calendar" through date. 

New measure: Fact(WeekNow) , 

 

Fact_weekNow = calculate(sum(fact);
filter(Calendar;calendar[weekNum] = WEEKNUM(max('Fact'[Date]);2))
Fact_weekPr = calculate(sum(fact);
filter(Calendar;calendar[weekNum] = WEEKNUM(max('Fact'[Date]);2)-1)
WeekNowVSWeekPr= Fact_weekNow /Fact_weekPr -1

Filter for weeks should be used from the calendar table, then you can see empty weeks if you need look fact at period

 

 

 

Hi @Anonymous 

 

I want to know why you use 2 for followings,

WeekNum = WEEKNUM('calendar'[Date];2) 
where 2 -start week on Monday

 

Fact_weekNow = calculate(sum(fact);
filter(Calendar;calendar[weekNum] = WEEKNUM(max('Fact'[Date]);2))
Fact_weekPr = calculate(sum(fact);
filter(Calendar;calendar[weekNum] = WEEKNUM(max('Fact'[Date]);2)-1)

 

In my data set i have client details. I want to get the difference betweeen previous week client values with this week.

 

 - In your formula you used sum(fact) so in my formula do i need to use sum(clients) ?

- Do i need to create a seperate calender to calculate the data?

 

regards,

cham

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.