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! It's time to submit your entry. Live now!
Hi,
Is it possible to create a column which has dynamic data based upon the slicer? For example,
A project has a start date and an end date. I will have a slicer in whcih I will specify a range of dates. Then, my column will give me the number of days that project has in the selected range of dates.
Solved! Go to Solution.
Hi @SaurabhGupta,
Try this formula please.
Measure =
VAR minDate =
MIN ( 'calendar'[date] )
VAR maxDate =
MAX ( 'calendar'[date] )
VAR startDate =
MIN ( project[start date] )
VAR endDate =
MIN ( project[end date] )
RETURN
SWITCH (
TRUE (),
startDate < minDate
&& endDate < minDate, 0,
startDate > maxDate
&& endDate > maxDate, 0,
startDate < minDate
&& endDate > maxDate, DATEDIFF ( minDate, maxDate, DAY ),
startDate < minDate
&& endDate > minDate
&& endDate < maxDate, DATEDIFF ( minDate, endDate, DAY ),
endDate > minDate
&& endDate < maxDate
&& startDate > minDate
&& startDate < maxDate, DATEDIFF ( startDate, endDate, DAY ),
endDate > maxDate
&& startDate > minDate
&& startDate < maxDate, DATEDIFF ( startDate, maxDate, DAY )
)
Best Regards,
Dale
Yes,if your data model has the supporting data, this is possble.
Thanks
Raj
Thanks Raj,
Could you please tell me how to do that?
I have Project start date, project end date, and a calendar table (that will be used in a slicer for selecting the range of dates).
How can I create a new column in my project table which will show the number of days that a project has in the selected range of dates?
Hi @SaurabhGupta,
Try this formula please.
Measure =
VAR minDate =
MIN ( 'calendar'[date] )
VAR maxDate =
MAX ( 'calendar'[date] )
VAR startDate =
MIN ( project[start date] )
VAR endDate =
MIN ( project[end date] )
RETURN
SWITCH (
TRUE (),
startDate < minDate
&& endDate < minDate, 0,
startDate > maxDate
&& endDate > maxDate, 0,
startDate < minDate
&& endDate > maxDate, DATEDIFF ( minDate, maxDate, DAY ),
startDate < minDate
&& endDate > minDate
&& endDate < maxDate, DATEDIFF ( minDate, endDate, DAY ),
endDate > minDate
&& endDate < maxDate
&& startDate > minDate
&& startDate < maxDate, DATEDIFF ( startDate, endDate, DAY ),
endDate > maxDate
&& startDate > minDate
&& startDate < maxDate, DATEDIFF ( startDate, maxDate, DAY )
)
Best Regards,
Dale
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 50 | |
| 42 | |
| 36 | |
| 31 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 129 | |
| 59 | |
| 48 | |
| 47 |