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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Calculation of Sales between two dates, then calculation of Sales one week ago since this date

Dears,

My idea is to calculate Sales between two dates in my shops, when special offers for clients started and ended, then I would like to calculate Sales one week ago since this date.

For example, special offers for clients started 15/05/2021 and ended 19/05/2021. I calculated Sales for these periods, then I would like to calculate Sales in these periods between 08/05/2021 and 12-05-2021.

 

There are columns in my table:

A column with Sales [Sales], a column with dates [Date] from 1/01/2021 to 26/12/2021, a column with special offers [Special offers] and a column with dates [DateOfPromotion] for these special offers (the lenght of the promotion). 

I calculated Sales 

Sales = sum(Table[Sales])

Therefore, I calculated when my promotion started and ended:

Start Promotion= min(Table[DateOfPromotion])
End Promotion= max(Table[DateOfPromotion])

Then, I calculated Sales between these dates:

Sales in this promotion= calculate(Sales,DATESBETWEEN([Table[Date],[Start Promotion],[End Promotion]))
Next, I calculated Sales between these dates seven days ago
First, I calculated date seven days ago from the promotion date:
Start Promotion one week ago= min(Table[DateOfPromotion]) - 7
End Promotion one week ago= MAX(Table[DateOfPromotion]) - 7
Then, I calculated Sales between these dates:
Sales one week ago= calculate(Sales,DATESBETWEEN([Table[Date],[Start Promotion one week before],[End Promotion one week before]))
Finally, I put all measurements in one table, because I would like to compare Sales in this promotion, then Sales one week ago (when it did not take place):
promotion.JPG
 
As you can see my idea does not work.
I tried to use Calendar Table, but I obtained the same results.
I was wondering what I did wrongly.
 
Would you be so kind as to give me your advice how to deal with it properly?
I would apperciate it if you could write your measurement (DAX) with an obvious explanation.
 
I am looking forward to receiving your ideas.
 
L.
 
 
2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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
Anonymous
Not applicable

I shared this table output:

promotion.JPG

Is it enough for you ?

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors