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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Junaid11
Helper V
Helper V

Same Sales last year as per working days

Hello,
I calculated working days with the below formula.

Working Day Outcome Column =
  VAR __Date = 'Invoice Date'[InvoiceDate]
  VAR __WeekDay = WEEKDAY(__Date,2)
  VAR __MonthStart = DATE(YEAR(__Date),MONTH(__Date),1)
  VAR __NetWorkDays = NETWORKDAYS(__MonthStart, __Date)
RETURN
  IF(__WeekDay < 6, __NetWorkDays,BLANK())


It is working perfectly fine. Now I want to calculate sales for same period last year based on these working days like if 1st working day of october 2022 is 3000 then what would be of 1st working day of October 2021. I was using sameperiodlastyear butit takes date instead if day. How can I use these working days as comparison, Your help would be highly appreciated.
Thank you

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @Junaid11 ,

 

You can try this method:

I create two tables as the sample data:

vyinliwmsft_0-1669102619075.png

 

In the Invoice Data table, new some columns:

Sales = CALCULATE(SUM(Sales[Sales]), FILTER('Sales','Sales'[Date] = 'Invoice Date'[InvoiceDate]))
Month = MONTH('Invoice Date'[InvoiceDate])
Year = YEAR('Invoice Date'[InvoiceDate])
LastYearWorkDaySales =
CALCULATE (
    SUM ( 'Invoice Date'[Sales] ),
    FILTER (
        'Invoice Date',
        'Invoice Date'[Month] = EARLIER ( 'Invoice Date'[Month] )
            && 'Invoice Date'[Year]
                = EARLIER ( 'Invoice Date'[Year] ) - 1
            && 'Invoice Date'[Working Day Outcome Column]
                = EARLIER ( 'Invoice Date'[Working Day Outcome Column] )
            && NOT ( ISBLANK ( 'Invoice Date'[Working Day Outcome Column] ) )
    )
)

The result is:

vyinliwmsft_1-1669102619076.png

 

vyinliwmsft_2-1669102619077.png

 

Hope this helps you.

Here is my PBIX file.

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @Junaid11 ,

 

You can try this method:

I create two tables as the sample data:

vyinliwmsft_0-1669102619075.png

 

In the Invoice Data table, new some columns:

Sales = CALCULATE(SUM(Sales[Sales]), FILTER('Sales','Sales'[Date] = 'Invoice Date'[InvoiceDate]))
Month = MONTH('Invoice Date'[InvoiceDate])
Year = YEAR('Invoice Date'[InvoiceDate])
LastYearWorkDaySales =
CALCULATE (
    SUM ( 'Invoice Date'[Sales] ),
    FILTER (
        'Invoice Date',
        'Invoice Date'[Month] = EARLIER ( 'Invoice Date'[Month] )
            && 'Invoice Date'[Year]
                = EARLIER ( 'Invoice Date'[Year] ) - 1
            && 'Invoice Date'[Working Day Outcome Column]
                = EARLIER ( 'Invoice Date'[Working Day Outcome Column] )
            && NOT ( ISBLANK ( 'Invoice Date'[Working Day Outcome Column] ) )
    )
)

The result is:

vyinliwmsft_1-1669102619076.png

 

vyinliwmsft_2-1669102619077.png

 

Hope this helps you.

Here is my PBIX file.

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Greg_Deckler
Community Champion
Community Champion

@Junaid11 You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.