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
Rafaelhk
Frequent Visitor

Datediff using allselected and slicer

I have a database that compiles information received from several organization and I have to keep track on how many days has passed since the last submission.

 

I am doing it using this measure:

Overall last submission date = calculate(MAX(Submissions[last_submission_date]), ALLSELECTED(Submissions))

 

And then the min of this column

Days from last submissoin= DATEDIFF(Submissions[last_submission_date], Submissions[Overall last submission date], DAY)
 
 
When not filtered, the result is as expected:
OrganizationLast submission DateOverall last submission DateDays from last submission
A14/8/202219/9/202236
B19/9/202219/9/20221
 
The problem is when I filter the submission by year, using a slicer:
Expected:
OrganizationLast submission DateOverall last submission DateDays from last submission
A31/12/202131/12/20210
B31/12/202131/12/20210
 
What I get:
OrganizationLast submission DateOverall last submission DateDays from last submission
A31/12/202131/12/2021262
B31/12/202131/12/2021262
 
Any thoughts on why this is happening?
 
 
1 ACCEPTED SOLUTION

@amitchandak ,

 

Thank you for the reply. Although your formula did not work, you pointed me in the right direction.

 

This is the formular that worked:

 
Days from last submission = CALCULATE(DATEDIFF(MAX(Submissions[last_submission_date]),Submissions[Overall last submission date], DAY))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Rafaelhk , The second one needs to be a measure too

 

Days from last submissoin= DATEDIFF(Max(Submissions[last_submission_date]), Submissions[Overall last submission date], DAY)

 

 

sumx(values(Submissions[Organization]) ,calculate(DATEDIFF(Max(Submissions[last_submission_date]), Submissions[Overall last submission date], DAY) ) )

@amitchandak ,

 

Thank you for the reply. Although your formula did not work, you pointed me in the right direction.

 

This is the formular that worked:

 
Days from last submission = CALCULATE(DATEDIFF(MAX(Submissions[last_submission_date]),Submissions[Overall last submission date], DAY))

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.