Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello,
first post in this forum!
I'm struggling to get a workaround the following issue:
I've created some visuals where I can follow the day to day cumulative (month to date) sales for a specific month.
Based on a slicer, I select a certain date in the month and would like to compare the month to date sales value with the same month last year, but the related date, last year, should be the one that has the same amount of working days left as the date I selected in the filter.
I used the function NETWORKINGDAYS to determine how many working days are left in the month for which I picked the date, but how to get the relevant date in the month of previous year.
For the ease of understanding, assume that only Saturday and Sundays are non working days.
Any help is welcome!
The formula used to determine the working days left based on selection is:
Thanks, Jan
Solved! Go to Solution.
Hi, @Jan_Cools
May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.
Measures:
Remaining_Work_Days =
VAR remaining_Work_Days =
NETWORKDAYS ( SELECTEDVALUE ( 'Table'[Date] ), ENDOFMONTH ( 'Table'[Date] ), 1 )
RETURN
remaining_Work_Days
SameWorkingDayLastYear =
VAR SelectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR SameDayLastYear =
SAMEPERIODLASTYEAR ( 'Table'[Date] )
VAR SameMonthLastYear =
EOMONTH ( SelectedDate, -12 )
VAR WorkingDaysLastYear =
NETWORKDAYS ( SameDayLastYear, SameMonthLastYear )
RETURN
WorkingDaysLastYear
TrueValuesLastYear =
VAR DIFFDAYS = [Remaining_Work_Days] - [SameWorkingDayLastYear]
VAR SelectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR SameDayLastYear =
SAMEPERIODLASTYEAR ( 'Table'[Date] )
VAR StartMonthLastYear =
EOMONTH ( SelectedDate, -13 ) + 1
VAR _tureSameDayLastYear =
SWITCH (
DIFFDAYS,
-1,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear + 1 ) = 7, SameDayLastYear + 3,
WEEKDAY ( SameDayLastYear + 1 ) = 1, SameDayLastYear + 2,
SameDayLastYear + 1
),
-2,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear + 2 ) = 7, SameDayLastYear + 4,
WEEKDAY ( SameDayLastYear + 2 ) = 1, SameDayLastYear + 3,
SameDayLastYear + 2
),
-3,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear + 3 ) = 7, SameDayLastYear + 5,
WEEKDAY ( SameDayLastYear + 3 ) = 1, SameDayLastYear + 4,
SameDayLastYear + 3
),
1,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear - 1 ) = 7, SameDayLastYear - 2,
WEEKDAY ( SameDayLastYear - 1 ) = 1, SameDayLastYear - 3,
SameDayLastYear - 1
),
2,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear - 2 ) = 7, SameDayLastYear - 4,
WEEKDAY ( SameDayLastYear - 2 ) = 1, SameDayLastYear - 3,
SameDayLastYear - 2
),
3,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear - 3 ) = 7, SameDayLastYear - 5,
WEEKDAY ( SameDayLastYear - 3 ) = 1, SameDayLastYear - 4,
SameDayLastYear - 3
),
SameDayLastYear
)
VAR _ValuesLastYear =
CALCULATE (
SUM ( 'CALENDAR'[Value] ),
'CALENDAR'[Date] >= StartMonthLastYear
&& 'CALENDAR'[Date] <= _tureSameDayLastYear
)
RETURN
_ValuesLastYear
ValuesThisYear =
VAR SelectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR DateStartOfMonth =
EOMONTH ( SelectedDate, -1 ) + 1
VAR _ValuesThisYear =
CALCULATE (
SUM ( 'CALENDAR'[Value] ),
'CALENDAR'[Date] >= DateStartOfMonth
&& 'CALENDAR'[Date] <= SelectedDate
)
RETURN
_ValuesThisYear
If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi, @Jan_Cools
May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.
Measures:
Remaining_Work_Days =
VAR remaining_Work_Days =
NETWORKDAYS ( SELECTEDVALUE ( 'Table'[Date] ), ENDOFMONTH ( 'Table'[Date] ), 1 )
RETURN
remaining_Work_Days
SameWorkingDayLastYear =
VAR SelectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR SameDayLastYear =
SAMEPERIODLASTYEAR ( 'Table'[Date] )
VAR SameMonthLastYear =
EOMONTH ( SelectedDate, -12 )
VAR WorkingDaysLastYear =
NETWORKDAYS ( SameDayLastYear, SameMonthLastYear )
RETURN
WorkingDaysLastYear
TrueValuesLastYear =
VAR DIFFDAYS = [Remaining_Work_Days] - [SameWorkingDayLastYear]
VAR SelectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR SameDayLastYear =
SAMEPERIODLASTYEAR ( 'Table'[Date] )
VAR StartMonthLastYear =
EOMONTH ( SelectedDate, -13 ) + 1
VAR _tureSameDayLastYear =
SWITCH (
DIFFDAYS,
-1,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear + 1 ) = 7, SameDayLastYear + 3,
WEEKDAY ( SameDayLastYear + 1 ) = 1, SameDayLastYear + 2,
SameDayLastYear + 1
),
-2,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear + 2 ) = 7, SameDayLastYear + 4,
WEEKDAY ( SameDayLastYear + 2 ) = 1, SameDayLastYear + 3,
SameDayLastYear + 2
),
-3,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear + 3 ) = 7, SameDayLastYear + 5,
WEEKDAY ( SameDayLastYear + 3 ) = 1, SameDayLastYear + 4,
SameDayLastYear + 3
),
1,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear - 1 ) = 7, SameDayLastYear - 2,
WEEKDAY ( SameDayLastYear - 1 ) = 1, SameDayLastYear - 3,
SameDayLastYear - 1
),
2,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear - 2 ) = 7, SameDayLastYear - 4,
WEEKDAY ( SameDayLastYear - 2 ) = 1, SameDayLastYear - 3,
SameDayLastYear - 2
),
3,
SWITCH (
TRUE (),
WEEKDAY ( SameDayLastYear - 3 ) = 7, SameDayLastYear - 5,
WEEKDAY ( SameDayLastYear - 3 ) = 1, SameDayLastYear - 4,
SameDayLastYear - 3
),
SameDayLastYear
)
VAR _ValuesLastYear =
CALCULATE (
SUM ( 'CALENDAR'[Value] ),
'CALENDAR'[Date] >= StartMonthLastYear
&& 'CALENDAR'[Date] <= _tureSameDayLastYear
)
RETURN
_ValuesLastYear
ValuesThisYear =
VAR SelectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR DateStartOfMonth =
EOMONTH ( SelectedDate, -1 ) + 1
VAR _ValuesThisYear =
CALCULATE (
SUM ( 'CALENDAR'[Value] ),
'CALENDAR'[Date] >= DateStartOfMonth
&& 'CALENDAR'[Date] <= SelectedDate
)
RETURN
_ValuesThisYear
If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Perfect @Anonymous Yang!
seems to be working as expected.
Thanks a lot.
If you can share sample file it will be great
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 8 | |
| 5 | |
| 3 |
| User | Count |
|---|---|
| 28 | |
| 21 | |
| 20 | |
| 18 | |
| 12 |