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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Himanshi0291
Helper II
Helper II

Need help with days between dates in Slicer

Hi,

 

I am facing a difficulty in calculating total days between the dates selected in slicer for a scenario listed below - 

 

I have a Trans date column and interval for the same is selected in slicer and employees are required to post their working hours for each date in the month but for some reason, some always miss. 

 

Himanshi0291_0-1593801620095.png

Now, I want to calculate total days between the interval selected in slicer given above in table (column Trans date) irrespective of employee hours present or not. 

 

Problem - When I try to calulcate days between 15/06/2020 to 28/06/2020, my query gives me only 4 days i.e. days for which employee put the data but my need is to calculate total days between 15/06/2020 to 28/06/2020 (or any interval selected in slicer).  

 

Please guide how could that be achieved. 

11 REPLIES 11
harshnathani
Community Champion
Community Champion

Hi @Himanshi0291 ,

 

You can have a look at this video . See if this helps

 

https://www.youtube.com/watch?v=mm-Lv6lv4a4

 


Regards,

Harsh Nathani


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

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

Ashish_Mathur
Super User
Super User

Hi,

Build your slicer from the Trans Date column and select any date range.  Write this measure

=MAX(Data[Trans date])-MIN(Data[Trans date])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

We tried using the expression suggested but it didnt work. 

Here is my expression -

Days = MAX(DK_Time_Temp[TransDate] - MIN(DK_Time_Temp[TransDate]))
It throws the error that MAX function only accepts a column reference as an argument.
But Transdate is already a column in table DK_TIME_TEMP. 

Please help. 

 

Capture.PNG

Hi @Himanshi0291 ,

 

Please try measure like this:

Measure = 
var max_date = CALCULATE(MAX('Table'[Trans Date]),ALLSELECTED('Table'[Trans Date]))
var min_date = CALCULATE(MIN('Table'[Trans Date]),ALLSELECTED('Table'[Trans Date]))
return DATEDIFF(min_date,max_date,DAY)

test_Need help with days between dates in Slicer.PNG

 

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

Thanks for all your solutions & support.

With the help of MAX and MIN function, I am getting the maximum & minimum date seleted in slicer but it does not calculate working days between the two dates if there is no data available for some dates.

 

Here in the snapshot below, my slicer has min date of 15/06 and max date of 28/06 however count of my total working days is still 5 i.e. from 15/06 to 19/06 for which data is available in table. My need is to calculate total working days between 15/06 to 28/06 irrespective of the fact that data is available or not for those dates in table. 

 

Capture2.PNG

 

What could be the best possible way to achieve the same? 

 

 

 

 

Hi Team,

 

Can anyone help me with this query?

 

Thank you in advance.

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

The MAX bracket should be closed before the - sign.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry, the suggestion didn't help.

 

I tried:  Days = MAX(DK_Time_Temp[TransDate])-MIN(DK_Time_Temp[TransDate])

Outcome is weird: 10-01-1900 00:00:00

Hi @Himanshi0291 ,

 

 

See if this helps.

 

https://community.powerbi.com/t5/Desktop/Days-Between-Slicer-Dates-in-Measure/m-p/608387

https://community.powerbi.com/t5/Desktop/Measure-with-Date-from-Slicer/m-p/1144897

 


Regards,

Harsh Nathani


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

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

lbendlin
Super User
Super User

for your date value in the visual enable "show items with no data"

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors