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
HI,
I am looking to make the YTD measure to be dynamic based on a input parameter.
This input parameter then will be used a slicer in power pivot.
For ex:
To calculate YTD, we use :
IsYTD = IF( YEAR(Calendar[DateSK]) = YEAR(TODAY()) && Calendar[DateSK]<TODAY(),1,0)
But above TODAY() is hardcoded and I am trying to make it dynamic so that YTD is calculateed based on users preference
Looking for more a function like feature in M.
something like :
VAR pickdate = date(2018,2,1) -- pickdate to be a slicer
IsYTD = IF( YEAR(Calendar[DateSK]) = YEAR(pickdate) && Calendar[DateSK]<pickdate,1,0)
I tried to create a new datetable and reference it in above query by joining the relationship with Calendar table but it doesnt seem to calculate YTD dynamically.
Solved! Go to Solution.
Hello,
By using a WhatIf parameter, you may let the users choose their parameters dynamically.
I created a simple table :
I then created a WhatIf parameter :
LastDays = GENERATESERIES(0; 50; 1)
Inside the data table, I added 3 new measures :
Date Min = DATE(YEAR(TODAY()-LastDays[Last DAys Val]);1;1)
Date Max = TODAY()-LastDays[Last DAys Val]
Sales YTD =
SUMX(
FILTER(Data;AND(Data[Date]<[Date Max];Data[Date]>= [Date Min]));
Data[Units])
When users change the value of LastDays on a slicer, it will dynamically change the scope :
Hello,
By using a WhatIf parameter, you may let the users choose their parameters dynamically.
I created a simple table :
I then created a WhatIf parameter :
LastDays = GENERATESERIES(0; 50; 1)
Inside the data table, I added 3 new measures :
Date Min = DATE(YEAR(TODAY()-LastDays[Last DAys Val]);1;1)
Date Max = TODAY()-LastDays[Last DAys Val]
Sales YTD =
SUMX(
FILTER(Data;AND(Data[Date]<[Date Max];Data[Date]>= [Date Min]));
Data[Units])
When users change the value of LastDays on a slicer, it will dynamically change the scope :
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |