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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
BJohnson_79
New Member

Workday Adjusted Date Logic

I am trying to create date logic that would identify the current year workday and return sales from that same workday in the prior year. With the holidays so far this year, the issue i'm getting is my returned data is off by 1 workday.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @BJohnson_79 ,

 

I created some data:

Table:

vyangliumsft_0-1705892323601.png

holiday table:

vyangliumsft_1-1705892323601.png

Here are the steps you can follow:

1. Create calculated column.

Test =
var _week=WEEKDAY('Table'[Date],2)
var _column=SELECTCOLUMNS('holiday table',"date",[Date])
return
IF(
  'Table'[Date] in _column ||   _week in {6,7},0,1)
Workday =
IF(
    [Test]=0,BLANK(),
RANKX(
    FILTER(ALL('Table'),
    YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&[Test]=1),'Table'[Date],,ASC)
)
Current =
IF(
    YEAR('Table'[Date])= YEAR(TODAY()),
    "Currrent Year")

vyangliumsft_2-1705892337005.png

2. Create measure.

compare =
var _lastyear=
MAXX(
    FILTER(ALL('Table'),
    YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))-1&&'Table'[Workday]=MAX('Table'[Workday])),[Date])
var _value=
SUMX(
    FILTER(ALL('Table'),'Table'[Date]=_lastyear),[Value])
return
IF(
    MAX('Table'[Test])=BLANK(),BLANK(),
MAX('Table'[Value])- _value)

3. Result:

vyangliumsft_3-1705892337011.png

 

 

Best Regards,

Liu Yang

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

5 REPLIES 5
Anonymous
Not applicable

Hi  @BJohnson_79 ,

 

I created some data:

Table:

vyangliumsft_0-1705892323601.png

holiday table:

vyangliumsft_1-1705892323601.png

Here are the steps you can follow:

1. Create calculated column.

Test =
var _week=WEEKDAY('Table'[Date],2)
var _column=SELECTCOLUMNS('holiday table',"date",[Date])
return
IF(
  'Table'[Date] in _column ||   _week in {6,7},0,1)
Workday =
IF(
    [Test]=0,BLANK(),
RANKX(
    FILTER(ALL('Table'),
    YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&[Test]=1),'Table'[Date],,ASC)
)
Current =
IF(
    YEAR('Table'[Date])= YEAR(TODAY()),
    "Currrent Year")

vyangliumsft_2-1705892337005.png

2. Create measure.

compare =
var _lastyear=
MAXX(
    FILTER(ALL('Table'),
    YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))-1&&'Table'[Workday]=MAX('Table'[Workday])),[Date])
var _value=
SUMX(
    FILTER(ALL('Table'),'Table'[Date]=_lastyear),[Value])
return
IF(
    MAX('Table'[Test])=BLANK(),BLANK(),
MAX('Table'[Value])- _value)

3. Result:

vyangliumsft_3-1705892337011.png

 

 

Best Regards,

Liu Yang

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

BJohnson_79
New Member

Based on the calendar, data Jan1- Jan18 of 2024 13 workdays.  The same period last year had 12 workdays due to Jan2 being an observed holiday.  

I am trying to write an expression that would identify the current year workday number, and compare it to the same workday number in the previous year, despite the calendar day being different.

Is there any column you are maintaining to identify that pasrticular date as a Holiday ?

Yes, my date table contains workday data for current year and prior year

Gayatri_D05
Resolver II
Resolver II

Hi @BJohnson_79 ,
While trying to undertstand your question, I am confused as to what result are you expecting if the current year has holiday and the prior year too ?
Should be taking day-1 ?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.