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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Dlahey
Helper I
Helper I

Comparing 2 Custom Time Periods to Calculate Sales based on # of Sales Dates

Hi Friends,

 

I have completed following an amazing thread of half year time intelligence:

https://amitchandak.medium.com/half-year-time-intelligence-b8ba09b90b9e 

 

I was hoping to get some support here with my formula for LHYTD - last half year to date as I require some customizations:

 

LHYTD = CALCULATE([Net], FILTER(all('Calendar'), 'Calendar'[Half Year Rank] = max('Calendar'[Half Year Rank])-1 && 'Calendar'[Day of Half] <= max('Calendar'[Day of Half])))

 

Currently, this formula will calculate all Sales from dates Jul-Dec since my date table is uploaded for entire year 2023. This is because it thinks dates up to Jun 30th, 2023 is complete vs. using today's date.

When comparing Half to date as of today May 29th, there are 134 days with sales. This was calculated using:

               # of Days Half to-date = calculate(
                          counta(Working_Days[Reference Date].[Date]),
                          FILTER(Working_Days,Working_Days[Is blank sales] > 0 &&
                          (Working_Days[Year Half]=202301)))
 
Is there a way to somehow leverage the count of 134 days and integrate it into the Last Half Year to Date formula to compare Jul 2022 +134 days?
 
Any help would be greatly appreciated.
 
Thanks,
2 REPLIES 2
Anonymous
Not applicable

Hi @Dlahey,

You can try to use the following measure formula to get the rolling previous half year to date results based on current date:

LHYTD =
VAR currDate =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        [Net],
        FILTER (
            ALLSELECTED ( 'Working_Days' ),
            Working_Days[Is blank sales] > 0
                && 'Working_Days'[Date]
                    >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 6, 1 )
                && 'Working_Days'[Date] <= currDate
        )
    )

Regards,

Xiaoxin Sheng

thank you so much for your time and expertise. I think this gets me really close to my desired solution.

 

my var currDate = 12/31/2023

Dlahey_0-1685542118099.png

is there a way to add to the variable max date = working_days.[date] where blank sales are >0?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.