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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Siboska
Helper II
Helper II

Calculate Datediff between month based on month selected in slicer

Hi, 

Calculate difference between:
Baseline “Planned end date” (Planned end date from the earliest month selected in snapshot slicer) and Planned End date from the last month selected in the snapshot slicer per project.


Siboska_0-1665067285155.png


In the above selection it would be a measure calculating the DateDiff between “May” and “Current”(October) which in row 1 corresponds to 2/17/2022 and 12/8/2022 which should equal 294 days delay.


If I Change the slicer from Current to June it should be 2/17/2022 and 2/17/2022 which should equal 0. 
Let me know if I need to elaborate further

1 ACCEPTED SOLUTION

Hi @Siboska 

I'm not on my computer right now, but I can advise you the following. 
Since you are using a matrix visual then you can utilize the totals column to disply the required result. 

=
IF (
    ISINSCOPE ( Peojects[Snapshot Name] ),
    SELECTEDVALUE ( Projects[Planned EndDate] ),
    DATEDIFF (
        MIN ( Projects[Planned EndDate] ),
        MAX ( Projects[Planned EndDate] ),
        DAY
    )
)

Activate the column totals and rename it then use this measure in the matrix  

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Siboska 

the slicer from which table/column? 
do you have a date table? Does it contain a YYYYMM format column?

I guess the Planned EndDate column is MAX or MIN aggregated in the matrix. Is that correct?

What is the name of the table that contains the Planned EndDate column?

I have tried to map everything out and make the context better:
The data model contains of 2 tables. Projects and Snap shots


Siboska_0-1665116300155.png

 

Hi @Siboska 

The snapshot name used in the slicer and the matrix from which table? Any relationship between the two tables? Is it a real date or text  data type?

Hi, 

There is a One- to many relationship from Table: SnapShot --> Project.
It is real dates

Hi @Siboska 

I'm not on my computer right now, but I can advise you the following. 
Since you are using a matrix visual then you can utilize the totals column to disply the required result. 

=
IF (
    ISINSCOPE ( Peojects[Snapshot Name] ),
    SELECTEDVALUE ( Projects[Planned EndDate] ),
    DATEDIFF (
        MIN ( Projects[Planned EndDate] ),
        MAX ( Projects[Planned EndDate] ),
        DAY
    )
)

Activate the column totals and rename it then use this measure in the matrix  

BITomS
Responsive Resident
Responsive Resident

Hi @Siboska,

 

Does something similar to the below get you to what you need?

 

Measure = datediff(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]),DAY)

 

Unfourtntly not.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.