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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I have a DAX Calendar created like this:
Solved! Go to Solution.
Hi @Anonymous ,
To what I can understand you want to calculate your in two weeks based on the last week day of past week so you need to add the weekday calculation to today try to use the following code:
Calendar =
VAR TodayWeekEnding =
TODAY ()
+ ( ( 7 - WEEKDAY ( TODAY () ) ) )
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ); 1; 1 ); TODAY () );
"Week Ending"; [Date]
+ ( ( 7 - WEEKDAY ( [Date] ) ) );
"IsCurrentWeek"; IF (
[Date] <= TODAY ();
IF ( [Date] >= TODAY () - ( WEEKDAY ( TODAY () ) - 1 ); 1; 0 );
0
);
"IsLast14Days"; IF (
[Date] <= TODAY ();
IF ( [Date] <= TodayWeekEnding - 7 && [Date] >= TodayWeekEnding - 14; 1; 0 );
0
);
"IsLast30Days"; IF ( [Date] <= TODAY (); IF ( [Date] >= TODAY () - 29; 1; 0 ); 0 )
)
Just adjust the bold part for the 30 and 90 days.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThis was close enough for me to get it to the values I was after, THANK YOU!
The VAR was the key that I wasn't thinkng of. Here is what I changed it to with an example:
Today is 4/24, the last 2 weeks ending values would be 4/7 - 4/20 (2 previous periods of weekening 4/20 and 4/13 which includes the dates of 4/7 - 4/13 and 4/14 - 4/20.
Formula:
Calendar =
VAR TodayWeekEnding =
TODAY ()
+ ( ( 7 - WEEKDAY ( TODAY () ) ) )
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ); 1; 1 ); TODAY () );
"Week Ending"; [Date]
+ ( ( 7 - WEEKDAY ( [Date] ) ) );
"IsCurrentWeek"; IF (
[Date] <= TODAY ();
IF ( [Date] >= TODAY () - ( WEEKDAY ( TODAY () ) - 1 ); 1; 0 );
0
);
"IsLast14Days"; IF (
[Date] <= TODAY ();
IF ( [Date] <= TodayWeekEnding - 7 && [Date] >= TodayWeekEnding - 20; 1; 0 );
0
);
"IsLast30Days"; IF ( [Date] <= TODAY (); IF ( [Date] >= TODAY () - 29; 1; 0 ); 0 )
)
Hi @Anonymous ,
Try to use the following calculation_:
Calendar =
VAR TodayWeekEnding =
TODAY ()
+ ( ( 7 - WEEKDAY ( TODAY () ) ) )
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ); 1; 1 ); TODAY () );
"Week Ending"; [Date]
+ ( ( 7 - WEEKDAY ( [Date] ) ) );
"IsCurrentWeek"; IF (
[Date] <= TODAY ();
IF ( [Date] >= TODAY () - ( WEEKDAY ( TODAY () ) - 1 ); 1; 0 );
0
);
"IsLast14Days"; IF (
[Date] <= TODAY ();
IF ( [Date] <= TodayWeekEnding - 7 && [Date] >= TodayWeekEnding - 14; 1; 0 );
0
);
"IsLast30Days"; IF ( [Date] <= TODAY (); IF ( [Date] >= TODAY () - 29; 1; 0 ); 0 )
)
The bold part is what you need to copy and adjust for 30 days and 90 days.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Anonymous ,
To what I can understand you want to calculate your in two weeks based on the last week day of past week so you need to add the weekday calculation to today try to use the following code:
Calendar =
VAR TodayWeekEnding =
TODAY ()
+ ( ( 7 - WEEKDAY ( TODAY () ) ) )
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ); 1; 1 ); TODAY () );
"Week Ending"; [Date]
+ ( ( 7 - WEEKDAY ( [Date] ) ) );
"IsCurrentWeek"; IF (
[Date] <= TODAY ();
IF ( [Date] >= TODAY () - ( WEEKDAY ( TODAY () ) - 1 ); 1; 0 );
0
);
"IsLast14Days"; IF (
[Date] <= TODAY ();
IF ( [Date] <= TodayWeekEnding - 7 && [Date] >= TodayWeekEnding - 14; 1; 0 );
0
);
"IsLast30Days"; IF ( [Date] <= TODAY (); IF ( [Date] >= TODAY () - 29; 1; 0 ); 0 )
)
Just adjust the bold part for the 30 and 90 days.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThis was close enough for me to get it to the values I was after, THANK YOU!
The VAR was the key that I wasn't thinkng of. Here is what I changed it to with an example:
Today is 4/24, the last 2 weeks ending values would be 4/7 - 4/20 (2 previous periods of weekening 4/20 and 4/13 which includes the dates of 4/7 - 4/13 and 4/14 - 4/20.
Formula:
Calendar =
VAR TodayWeekEnding =
TODAY ()
+ ( ( 7 - WEEKDAY ( TODAY () ) ) )
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ); 1; 1 ); TODAY () );
"Week Ending"; [Date]
+ ( ( 7 - WEEKDAY ( [Date] ) ) );
"IsCurrentWeek"; IF (
[Date] <= TODAY ();
IF ( [Date] >= TODAY () - ( WEEKDAY ( TODAY () ) - 1 ); 1; 0 );
0
);
"IsLast14Days"; IF (
[Date] <= TODAY ();
IF ( [Date] <= TodayWeekEnding - 7 && [Date] >= TodayWeekEnding - 20; 1; 0 );
0
);
"IsLast30Days"; IF ( [Date] <= TODAY (); IF ( [Date] >= TODAY () - 29; 1; 0 ); 0 )
)
Hi @Anonymous ,
Glad I could help, please mark the correct answer in order to help other as well.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsI am not seeing a option to mark as correct. I only am given the kudos options. Where is the mark as correct option?
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português
For some reason I do not.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThe Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 38 | |
| 38 | |
| 28 | |
| 27 |
| User | Count |
|---|---|
| 124 | |
| 88 | |
| 73 | |
| 66 | |
| 65 |