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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Resolver III
Resolver III

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors