cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Matthew77
Frequent Visitor

Measure to return value between two dates (start date and end date)

Hi,

 

I want to create a measure that returns the number of units between 2 dates. I have went through so many different types of codes I may be over complicating this for myself. I have a table with the following type of data :

 

Contract IDUnitsStart DateEnd Date
1231101/01/2000 30/06/2018
1231001/07/2018 01/04/2021
1231202/04/2021 

 

I want the measure to return the number of units. I have a chart with year as the axis but for some reason it doesnt seem to want to plot correctly to show how the number of unit changes over a given period of time. 

 

For example a chart to show when the number of units changed from 10 to 12 etc between two dates. I am able to produce the below manually by using a chart but I need it as a measure to add to another chart:

 

Matthew77_0-1627476686283.png

 

 

Thanks

1 ACCEPTED SOLUTION

Hi Amitchadak,

 

It would be like the below. I just wish to have a measure that will show how the number of units has changed over the years:

 

Matthew77_0-1627480839177.png

THIS CODE WORKED:

 

Units =
CALCULATE(
VALUES(Contract[Units]),
FILTER(
Contract,
Contract[EffectiveDate] <= MAX('Date'[Date])
&& Contract[EndDate] >= MIN('Date'[Date])
 
but to no avail. 

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@Matthew77 

The data you have provided and the explanation are not sufficient to understand your problem.
Please share sample data and the expected results.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Matthew77
Frequent Visitor

Hi I have added the example output

amitchandak
Super User
Super User

@Matthew77 , can you share the expected output?

 

I have two blogs they can offer some help

How to divide/distribute values between start date or end date or count days across months/days: https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Hi Amitchadak,

 

It would be like the below. I just wish to have a measure that will show how the number of units has changed over the years:

 

Matthew77_0-1627480839177.png

THIS CODE WORKED:

 

Units =
CALCULATE(
VALUES(Contract[Units]),
FILTER(
Contract,
Contract[EffectiveDate] <= MAX('Date'[Date])
&& Contract[EndDate] >= MIN('Date'[Date])
 
but to no avail. 

Actually after reloading that code seems to work! Thanks anyway 🙂

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors