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
PrathSable
Advocate II
Advocate II

Calculate current 4 weeks and previous 4 weeks based on date

Hi Guys,

I need to calculate revenue for current 4 weeks of the selected date and previous 4 weeks?

How can we achieve this? I have dates only for weeks

 

WhatsApp Image 2020-07-07 at 16.16.33.jpeg

 

Regards,

Prath Sable

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi @PrathSable 

First, you need to create a relationship between "Calendar" table and "MIS_Details" table

https://radacad.com/do-you-need-a-date-dimension

Now use all date field from calendar in the visual.

 

and then for measure[Previous 28 days Sales], remove .[Date] from the formula

Previous 28 days Sales = CALCULATE([Total Sales],DATEADD('Calendar'[reporting_date],-28,DAY))

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

@PrathSable , Check my Blog on week, Check for the last 12 week formula, just change that as per your need

 

Or use those as a filter in some other formula

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Hi @amitchandak :

 

The link you shared was the first thing I checked. Doesnt fulfill what I want to see 😞

 

What I want is when I select a date it should give me data for current 4 weeks and then the 4 weeks prior to that.

Also, it should give me the previous weeks dates and Gross Sales.

 

Attaching PBIX file for your reference.

https://drive.google.com/file/d/1Ij2Mcp1JsrvKWOIULaEiJzWNQZg5V7tU/view?usp=sharing 

 

Regards,

Prath Sable

@PrathSable , table 2 should be possible using my blog.

 

For table 1 and 3 , use relative Date slicer

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range

 

or this approach

https://www.youtube.com/watch?v=duMSovyosXE

 

I will try to check pbix in sometime

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.