Forum Discussion
QTR TARGET, PRESENT WEEK, LAST WEEK
To create a dynamic target measure for last week, you can use a combination of the IF and DATEDIFF functions in DAX. Here's an example of the formula you can use:
Last Week Target = IF( DATEDIFF( MAX('Date'[Date]), MAX('Table'[Date]), WEEK ) = 1, MAX('Table'[Current Week Target]), MAX('Table'[Previous Quarter Target]) )
In this formula, 'Date' is the table that contains the dates, and 'Table' is the table that contains the data you want to show. You'll need to replace these with the actual names of your tables.
The DATEDIFF function calculates the number of weeks between the current week and the week of the data in the 'Table' table. If this number is equal to 1, it means the data is from last week, so the formula uses the current week target. Otherwise, it means the data is from a previous week, so the formula uses the previous quarter target.
You can then use this measure in your visualizations to show the target for last week.