Forum Discussion
Dynamic measure/indicator based on selected date
Hi all, I would like to create a dynamic measure/indicator depending on a date, a simplified version of my problem is as follows:
The PortfolioOverview table contains the four columns below (with possible null values for the final two columns):
| Product | Status | Intro Date | Exit Date |
| A | Current Stock | ||
| B | Current Stock | 1-Oct | |
| C | To be introduced | 1-Sep | 1-Oct |
| D | To be introduced | 1-Oct |
I have created a separate Date table, from which I want to be able to select any date in the future. Based on this selected date, I want a measure, say inPortfolio, that indicates whether or not my Product is in my portfolio on the selected date:
- it indicates a '0' if the product is 'current stock' that remains in stock
- it indicates a '1' if the product is 'to be introduced' and the selected date has passed its intro date without passing a possible exit date
- it indicates a '-1' if my product has passed its exit date (for both current stock as well as future introductions)
Example: selecting Nov-1 as a date should result in the following:
| Product | Status | Intro Date | Exit Date | inPortfolio |
| A | Current Stock | 0 | ||
| B | Current Stock | 1-Oct | -1 | |
| C | To be introduced | 1-Sep | 1-Oct | -1 |
| D | To be introduced | 1-Oct | 1 |
I am able to create a Date table but I have difficulties with the 'inPortfolio' measure, any ideas how to achieve this?
Thank you in advance!
Anonymous , Try a measure like
Switch(true() ,
isblank(max([Intro Date])) && isblank(max([Exit Date])) , 0
isblank(max([Exit Date])) && max([Intro Date]) < selectedvalue(Date[Date]), 0
max([Exit Date]) < selectedvalue(Date[Date]) && max([Intro Date]) < selectedvalue(Date[Date]), -,
blank()
)
1 Reply
- amitchandakSuper User
Anonymous , Try a measure like
Switch(true() ,
isblank(max([Intro Date])) && isblank(max([Exit Date])) , 0
isblank(max([Exit Date])) && max([Intro Date]) < selectedvalue(Date[Date]), 0
max([Exit Date]) < selectedvalue(Date[Date]) && max([Intro Date]) < selectedvalue(Date[Date]), -,
blank()
)