cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Measure based on a date difference on a slicer

Hi, I just need a simple measure to count the number of days on a slicer filter.

If the start date on a slicer is 7/13/2020 and the end date 7/15/2020, I would like the measure to return a value of 2.
If the start date on a slicer is 7/13/2020 and the end date 7/17/2020, I would like the measure to return a value of 4.
If the start date on a slicer is 7/13/2020 and the end date 7/23/2020, I would like the measure to return a value of 10.


days.PNG


Any ideas on how to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Measure based on a date difference on a slicer

Hi @pal95 , 

You could create a table like below

slicer = CALENDAR(date(2020,1,1), date(2020,12,31))

Then use this in slicer and create measure like below

Measure = DATEDIFF( MIN(slicer[Date]),MAX(slicer[Date]),DAY)

 You could refer to my sample for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Super User II
Super User II

Re: Measure based on a date difference on a slicer

Hi @pal95 

In the most common case it will be looked like

Measure = DATEDIFF(MIN('Table'[Date]), MAX('Table'[Date]),DAY)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Highlighted
Super User IV
Super User IV

Re: Measure based on a date difference on a slicer

@pal95 , try like

measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return datediff(_min,_max,Day)


Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Champion
Community Champion

Re: Measure based on a date difference on a slicer

Hi @pal95 ,

 

 

Try this

 

measure =
VAR maxselval =
    MAXX (
        ALLSELECTED ( Date ),
        Date[Date]
    )
VAR minselval =
    MINX (
        ALLSELECTED ( Date ),
        Date[Date]
    )
RETURN
    DATEDIFF (
        maxselval,
        minselval,
        DAY
    )

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

Highlighted
Frequent Visitor

Re: Measure based on a date difference on a slicer

What should I put in Date[Date]? I would like to use the value on the slicer, so here, I would like to have a measure value of 11.

days.PNG

Highlighted
Community Support
Community Support

Re: Measure based on a date difference on a slicer

Hi @pal95 , 

You could create a table like below

slicer = CALENDAR(date(2020,1,1), date(2020,12,31))

Then use this in slicer and create measure like below

Measure = DATEDIFF( MIN(slicer[Date]),MAX(slicer[Date]),DAY)

 You could refer to my sample for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors