Home > OS >  Get Dynamic Date Difference in Power BI
Get Dynamic Date Difference in Power BI

Time:11-05

I am trying to get the difference between dates based on selected date values from a slicer.

From my image, the minimum date selected on the slicer is 5/10/2022 and the period to is all within 2022 therefore I was expecting a difference of less than 365. But it's subtracting 1/1/2008 which is the minimum date for my dates table. I created the DateX_col to see the minimum value being used; my intention is to have that column show the minimum value selected on the slicer. How can I achieve this? current implementation

I'm using MIN(CALENDAR[DATES]) to get the minimum value dynamically, and I'd also like the same for MAX values.

Also, DATEDIFF(MIN(CALENDAR[DATES]), PERIOD_TO,DAYS) is not picking from the slicer, rather it's picking from the minimum value of the table. So my column: DateX_col = MIN(CALENDAR[DATES]) is showing 1/1/2008 and my measure: date x = MIN(CALENDAR[DATES]) is showing 5/10/2022.

CodePudding user response:

It is not possible to get a dynamic MIN column in Power BI. We can get dynamic data differences by creating a measure([Periodto - Datex]) using the measure ([date x).

Periodto - Datex = DATEDIFF([date x], MIN(Table1[PERIOD_TO]), DAY)

enter image description here

  • Related