cancel
Showing results for
Did you mean:
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.

Any ideas on how to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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.

5 REPLIES 5
Highlighted
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

Highlighted
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)``````

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
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)

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.

Highlighted
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.

Announcements

#### August 2020 Community Challenge: Can You Solve These?

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

#### Community Blog

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

#### 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!

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

Top Solution Authors
Top Kudoed Authors