Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
tropic
Frequent Visitor

datediff for dates used in filters

I am struggling to find the correct dax expression for this. i have a date column which is used as a filter in the dashboard. then i have another column (deadline date) as part of the data. I wanted to create a column/measure that would give me the difference between whatever date is filtered and the deadline date. 

 

so for example, i filtered to Nov 10, and project 1 is due on Nov 30, the measure/column would give me 20 days as a result. 

 

the intention is to group the projects that are due in the next weeks/months using bucks/bins. any help?

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @tropic,

 

Taking into acount that you are using a slicer to filter your dashboard you need to create a measure, or different metrics depending on the bin.

 

The basic calculation will be something similar to this:

Days difference =
VAR _TempTable =
    ADDCOLUMNS (
        Table,
        "_DaysDifference", DATEDIFF ( Table[DeadlineDates], MAX ( SlicerTable[DateColumn] ), DAY )
    )
RETURN
    MAXX ( _TempTable, [_DaysDifference] )

 

This will give you the value per each line of your table of the difference then you need to calculate the buckets, this can be done using a table with the values of the bins.

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @tropic,

 

Taking into acount that you are using a slicer to filter your dashboard you need to create a measure, or different metrics depending on the bin.

 

The basic calculation will be something similar to this:

Days difference =
VAR _TempTable =
    ADDCOLUMNS (
        Table,
        "_DaysDifference", DATEDIFF ( Table[DeadlineDates], MAX ( SlicerTable[DateColumn] ), DAY )
    )
RETURN
    MAXX ( _TempTable, [_DaysDifference] )

 

This will give you the value per each line of your table of the difference then you need to calculate the buckets, this can be done using a table with the values of the bins.

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.