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

Return Campaigns that fall between the Start and End Date from Date Slicer

Hi,

 

I have been googling all day but have not managed to find a working solution for this one. If anyone can help would be greatly appreciated.

 

I have a Date Slicer set to between where I can pick a Start Date and an End Date.

 

I have a Table which contains a dataset of Campaigns which all have a Start Date and an End Date.

 

I would like to return any Campaigns whose Start Date and End Date fall between the Start Date and End date on the slicer.

 

For example if I have chosen 2018-08-01->2018-08-31 as the Date range for the slicer and I have a Campaign that runs from 2018-07-20->2018-08-2018 then this record should be returned.

 

I have looked at the below post that that seems to work based on a single date being chosen - not a range.

 

https://community.powerbi.com/t5/Desktop/Use-date-slicer-to-check-if-date-falls-between-two-dates/td...

 

Thanks for your help.

 

 

 

 

2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey,

 

create a Calendar table (let's assume that this table is called daterange), that is not related to your campaigns table.

 

Create a measure in your campaigns table like so:

measurename = 
var startDaterange = MIN('daterange'[date])
var endDaterange = MAX('daterange'[date])
return
SUMX(
'campaign'
,
var startcampaign = 'campaign'[startdate]
var endcampaign = 'campaign'enddate]
return[
if(
AND(...
,1
,BLANK()
)


Create the proper condition that marks each campaign that falls into the selected daterange.

 

Now you can use this message in the "Visual levels filter" band to filter the campaigns.

 

Please consider to create a PBIX file that contains sample data, upload the pbix file to onedrive or dropbox and share the link.

 

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

Greg_Deckler
Super User
Super User

These two Quick Measures show how to do this:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi @jkenne01,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

These two Quick Measures show how to do this:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
TomMartens
Super User
Super User

Hey,

 

create a Calendar table (let's assume that this table is called daterange), that is not related to your campaigns table.

 

Create a measure in your campaigns table like so:

measurename = 
var startDaterange = MIN('daterange'[date])
var endDaterange = MAX('daterange'[date])
return
SUMX(
'campaign'
,
var startcampaign = 'campaign'[startdate]
var endcampaign = 'campaign'enddate]
return[
if(
AND(...
,1
,BLANK()
)


Create the proper condition that marks each campaign that falls into the selected daterange.

 

Now you can use this message in the "Visual levels filter" band to filter the campaigns.

 

Please consider to create a PBIX file that contains sample data, upload the pbix file to onedrive or dropbox and share the link.

 

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.