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
Anonymous
Not applicable

Measure Calculating Between Dates Accurate at Day Level, but not Month Level

We've recently started using a temporal table for our data. Because of this we have records showing Valid To & Valid From dates.

I've created a measure to calculate the number of customers that are open on any given day. The measure below works at the DAY level, but when you use a date hierarchy includes all recrods that were valid at any point during that month, not just as of the last day of that month.

 

Total Open Customers =
CALCULATE(
COUNT('IA Dim_Customer'[CustomerKey]),FILTER('IA Dim_Customer',
'IA Dim_Customer'[Status] = "Open"
&& 'IA Dim_Customer'[ValidFrom].[Date] <= max('IA Dim_Date'[FullDate])
&& 'IA Dim_Customer'[ValidTo].[Date] > min('IA Dim_Date'[FullDate])))

 

Below are pictures that illustrate the issue better.

Capture.PNG

1 ACCEPTED SOLUTION
ElenaN
Resolver V
Resolver V

Hello,

 

If i understand correctly you want to show the open customers for the last day of the month (which applies also to higher levels - meaning last day of the quarter or the year).

 

If this is the case, then you have to modify your formula as follows:

 

Total Open Customers =
CALCULATE(
COUNT('IA Dim_Customer'[CustomerKey]),FILTER('IA Dim_Customer',
'IA Dim_Customer'[Status] = "Open"
&& 'IA Dim_Customer'[ValidFrom].[Date] <= max('IA Dim_Date'[FullDate])
&& 'IA Dim_Customer'[ValidTo].[Date] >= max('IA Dim_Date'[FullDate])))

 

That means positioning max(FullDate) - end of each interval - between the validity interval, between Valid From and Valid To.

 

Regards,

ElenaN

View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

You could try to refer to this post:

https://community.powerbi.com/t5/Desktop/Track-the-Workload-by-counting-the-number-of-in-progress-tasks/m-p/558856#M263486

 

Best Regards,

Lin

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

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/
ElenaN
Resolver V
Resolver V

Hello,

 

If i understand correctly you want to show the open customers for the last day of the month (which applies also to higher levels - meaning last day of the quarter or the year).

 

If this is the case, then you have to modify your formula as follows:

 

Total Open Customers =
CALCULATE(
COUNT('IA Dim_Customer'[CustomerKey]),FILTER('IA Dim_Customer',
'IA Dim_Customer'[Status] = "Open"
&& 'IA Dim_Customer'[ValidFrom].[Date] <= max('IA Dim_Date'[FullDate])
&& 'IA Dim_Customer'[ValidTo].[Date] >= max('IA Dim_Date'[FullDate])))

 

That means positioning max(FullDate) - end of each interval - between the validity interval, between Valid From and Valid To.

 

Regards,

ElenaN

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.