Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello, I am trying to add a column in my date calendar that says Yes if the week is last week compared to TODAY:
Solved! Go to Solution.
To handle the issue you're encountering with DirectQuery mode and the limitations of the IsLastWeek column, you can adjust your approach to calculate the last week dynamically without relying on the YEAR function. One way to achieve this is by comparing the date ranges directly. Here's how you can do it:
IsLastWeek =
IF (
AND (
DimDate[Date] >= TODAY() - WEEKDAY(TODAY()) - 6,
DimDate[Date] < TODAY() - WEEKDAY(TODAY()) + 1
),
"Yes",
"No"
)
To handle the issue you're encountering with DirectQuery mode and the limitations of the IsLastWeek column, you can adjust your approach to calculate the last week dynamically without relying on the YEAR function. One way to achieve this is by comparing the date ranges directly. Here's how you can do it:
Explanation:
Therefore, the condition DimDate[Date] >= TODAY() - WEEKDAY(TODAY()) - 6 checks if the date falls after the last day of the previous week, and DimDate[Date] < TODAY() - WEEKDAY(TODAY()) + 1 checks if the date falls before the first day of the current week.
This approach dynamically calculates the last week without relying on the year. It should work regardless of the year transition. Make sure your date table (DimDate) includes all the necessary dates for your analysis.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
To handle the issue you're encountering with DirectQuery mode and the limitations of the IsLastWeek column, you can adjust your approach to calculate the last week dynamically without relying on the YEAR function. One way to achieve this is by comparing the date ranges directly. Here's how you can do it:
IsLastWeek =
IF (
AND (
DimDate[Date] >= TODAY() - WEEKDAY(TODAY()) - 6,
DimDate[Date] < TODAY() - WEEKDAY(TODAY()) + 1
),
"Yes",
"No"
)
To handle the issue you're encountering with DirectQuery mode and the limitations of the IsLastWeek column, you can adjust your approach to calculate the last week dynamically without relying on the YEAR function. One way to achieve this is by comparing the date ranges directly. Here's how you can do it:
Explanation:
Therefore, the condition DimDate[Date] >= TODAY() - WEEKDAY(TODAY()) - 6 checks if the date falls after the last day of the previous week, and DimDate[Date] < TODAY() - WEEKDAY(TODAY()) + 1 checks if the date falls before the first day of the current week.
This approach dynamically calculates the last week without relying on the year. It should work regardless of the year transition. Make sure your date table (DimDate) includes all the necessary dates for your analysis.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Thanks! I worked just as I wanted!!
How would you go about doing the same thing but for the previous month?
To determine if a date belongs to the previous month, you can compare the month and year of the date with the month and year of the previous month. Here's how you can adjust your formula to achieve this:
IsPreviousMonth =
IF (
AND (
MONTH ( DimDate[Date] ) = MONTH ( TODAY() ) - 1,
YEAR ( DimDate[Date] ) = YEAR ( TODAY() )
)
||
AND (
MONTH ( DimDate[Date] ) = 12,
MONTH ( TODAY() ) = 1,
YEAR ( DimDate[Date] ) = YEAR ( TODAY() ) - 1
),
"Yes",
"No"
)
In this formula:
This adjusted formula should correctly identify whether a date belongs to the previous month without needing to filter directly by year.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
When I entered it into DAX, it says that there are too many arguments passed in this section:
||
AND (
MONTH ( DimDate[Date] ) = 12,
MONTH ( TODAY() ) = 1,
YEAR ( DimDate[Date] ) = YEAR ( TODAY() ) - 1
)
User | Count |
---|---|
57 | |
22 | |
18 | |
16 | |
11 |
User | Count |
---|---|
85 | |
54 | |
39 | |
21 | |
18 |