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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
unknown917
Helper III
Helper III

Count based on variable date range and start date

I have a table with a column that supplies a start date for a reopening of any given ID.  In another table I have the current and historical operating data for the ID by date with key items like sales qty.

 

I am in need of taking the reopening date as the starting point and calculate out in 28 day (4wk) increments the sales qty in each cycle before and since the reopen date. This is to run as a comparison of how the ID has performed before and since the repopen.

 

Since every reopen date can be different, how can I accomplish the date variability with the incremental summing or counting?

 

Thanks in advance!

 

 

2 REPLIES 2
techies
Resolver II
Resolver II

Hi @unknown917 

As I understand, create a RelativePeriod column that groups sales into 4-week periods before and after reopening by dividing the day difference by 28.

 

RelativePeriod =
VAR ReopenDate = LOOKUPVALUE(reopen[Reopen Date], reopen[ID], sales[ID])
VAR DaysDifference = DATEDIFF(ReopenDate, sales[Date], DAY)
RETURN INT(DaysDifference / 28)

 

And the Sales_4WeekPeriod measure then sums sales for each period, allowing performance comparison over time.

 

Sales_4WeekPeriod =
SUMX(
    VALUES(sales[RelativePeriod]),
    CALCULATE(
        SUM(sales[Sales Qty])
    )
)
 
Hope this works.

Thanks, @techies  - 

 

this resulted in returning all sales for the entire date range in 2nd table.  I need to be able to represent the 4 week increments, based on the go -live date

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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