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

Date Range Slicer (No Year)

Hello,

 

I have data from 1/1/2018-3/31/2020 and I want to see if I can show the sum of my values from 2/15-3/15 for all years 2018, 2019, and 2020.

 

So ideally I want to be able to show any range of time with the year as a legend. Has anyone tried doing this before?

Sample Picture.PNG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ahhines 

Assume you have date table and you have year as one of the column in that and you selected data from 15-feb to 15-march for any year

Have formula like this

measure =
var _max = format(maxx('Date','Date'[Date]),"MMDD")
var _min = format(Minx('Date','Date'[Date]),"MMDD")

return
CALCULATE(SUM(Data[Amount]), FILTER(all('Date'), format('Date'[Date],"MMDD") >=_min && format('Date'[Date],"MMDD") <=_max ))

 

Use year as a legend.

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@ahhines 

Assume you have date table and you have year as one of the column in that and you selected data from 15-feb to 15-march for any year

Have formula like this

measure =
var _max = format(maxx('Date','Date'[Date]),"MMDD")
var _min = format(Minx('Date','Date'[Date]),"MMDD")

return
CALCULATE(SUM(Data[Amount]), FILTER(all('Date'), format('Date'[Date],"MMDD") >=_min && format('Date'[Date],"MMDD") <=_max ))

 

Use year as a legend.

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Thanks! This is a great start. This is giving me a result three times the actual amount though. 

Pragati11
Super User
Super User

Hi @ahhines ,

 

Your requirement is not clear:

I have data from 1/1/2018-3/31/2020 and I want to see if I can show the sum of my values from 2/15-3/15 for all years 2018, 2019, and 2020.

 

What does the highlighted part mean here? Also provide some screenshots on your data and data model and what output is expected?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Sorry, I'm not sure why that was highlighted. I want to be able to select any date range, say 2/15-3/15, for years 2018, 2019, and 2020. Using a regular date filter from 2/15/2018-3/15/2020 would give me all days in this range and I do not want that. I want to just see the 2/15-3/15 period for each year. 

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.