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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Create Measure using Slicer and related Date

Hello Everyone,

 

I have tried to find a related solution but have been unable to find anything suitable. Apologies if there is already a solution out there for this.

 

I am trying to create a measure which uses a Slicer and then a corresponding date to provide a filtered output.

 

I have a Data table which has Date, Country, Time and Volume. The measure I would like to create is Time/Volume. In another Table I have Country in column A and Launch Date in column B. I would like to use a slicer to select the Country and then have two measures which use the Launch Date to provide the outcome of the calculation for before the launch date and after.

 

DateCountryTimeVolume
30/6/20France5100
1/7/20France7200
2/7/20France10400

 

CountryLaunch Date
UK24/6/20
France1/7/20
Belgium6/7/20

 

Example: I select the country France, which has a launch date of 1/7/20. Measure 1 provides the Time/Volume for before 1/7/20 and Measure 2 provides the Time/Volume for on and after 1/7/20.

 

Thanks for all your support!

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

you can try something like this:

 

Measure 1 = 
VAR __launchDate = MAX('Launch'[Launch Date])
RETURN
CALCULATE(SUM(Data[Volume]),Data[Date]<__launchDate)

 

but I would strongly recommend to create a separate tables for Countries and Calendar (to follow a star schema https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/)

Countries would be joining 1:Many with both Data and Launch tables, and Calendar joining with Data.

Then the code could look like this

 

Measure 1 = 
VAR __launchDate = MAX('Launch'[Launch Date])
RETURN
CALCULATE(SUM(Data[Volume]),Calendar[Date]<__launchDate)

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

4 REPLIES 4
Stachu
Community Champion
Community Champion

you can try something like this:

 

Measure 1 = 
VAR __launchDate = MAX('Launch'[Launch Date])
RETURN
CALCULATE(SUM(Data[Volume]),Data[Date]<__launchDate)

 

but I would strongly recommend to create a separate tables for Countries and Calendar (to follow a star schema https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/)

Countries would be joining 1:Many with both Data and Launch tables, and Calendar joining with Data.

Then the code could look like this

 

Measure 1 = 
VAR __launchDate = MAX('Launch'[Launch Date])
RETURN
CALCULATE(SUM(Data[Volume]),Calendar[Date]<__launchDate)

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Thanks @Stachu, I will try this out.

 

I actually have separate dimension tables for both Date and Country which i use for filtering or Slicers. Not sure if that makes a difference here. I do need to have the table which lists the launch date for all countries though.

Stachu
Community Champion
Community Champion

That's perfect, then the measure I posted will work, as long as you don't have a join between Calendar and Launch tables (when you filter Calendar it will push its filter context to Launch, and that's not what you want)



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Thank you, it has all worked perfectly!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors