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
bharukc
Helper I
Helper I

Number of ids that are fall under certain date range

Below is the sample table, I need to calculate

count of ids that occured between 1/1/2012-1/1/2013, 4/1/2012-4/1/2013, 7/1/2012-7/1/2013 and so on. How many Ids were due from the start of the quarter to a year from the start of quarter. IDs that fall under due between 1/1/2012-1/1/2013 will also be in 4/1/2012-4/1/2013, as they share common dates. 

Iddue date
11/3/2012
25/3/2012
38/3/2012
49/2/2012
51/4/2013
63/5/2013
74/9/2013
88/9/2013
99/10/2013
1 ACCEPTED SOLUTION

Hi, @bharukc 

 

It can be used only as a measure.

Create a new date table.

Date = CALENDAR(DATE(2012,1,1),DATE(2013,12,31))

Measure:

Measure = 
CALCULATE(COUNT('Table'[Id]),FILTER(ALL('Table'),[due date]>=MIN('Date'[Date])&&[due date]<=MAX('Date'[Date])))

vzhangti_3-1647503268887.pngvzhangti_1-1647503202579.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-zhangti
Community Support
Community Support

Hi, @bharukc 

 

Please check the following methods.

Measure:

2012/1/1-2013/1/1 = 
CALCULATE(COUNT('Table'[Id]),FILTER(ALL('Table'),[due date]>=DATE(2012,1,1)&&[due date]<=DATE(2013,1,1)))
2012/4/1-2013/4/1 = 
CALCULATE(COUNT('Table'[Id]),FILTER(ALL('Table'),[due date]>=DATE(2012,4,1)&&[due date]<=DATE(2013,4,1)))
2012/4/1-2013/4/1 = 
CALCULATE(COUNT('Table'[Id]),FILTER(ALL('Table'),[due date]>=DATE(2012,4,1)&&[due date]<=DATE(2013,4,1)))

vzhangti_0-1647415534856.png

Is this the result you were expecting?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@v-zhangti , yes the result is correct but I dont want to create measures for each date, I would rather have it as on measure so that I can create a chart with it. 

Hi, @bharukc 

 

It can be used only as a measure.

Create a new date table.

Date = CALENDAR(DATE(2012,1,1),DATE(2013,12,31))

Measure:

Measure = 
CALCULATE(COUNT('Table'[Id]),FILTER(ALL('Table'),[due date]>=MIN('Date'[Date])&&[due date]<=MAX('Date'[Date])))

vzhangti_3-1647503268887.pngvzhangti_1-1647503202579.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@bharukc , these are overlapping year ranges. You want to check they are on the start date of QTR or they are in a qtr or in these overlapping ranges

 

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

Hi @amitchandak , there will be overlapping time among these dates. I need to be able to count the id that fall under each date range multiple times. For eg, there might be 6 ids that fall under 1/1/2012-1/1/2013 range and 8 ids fall under 4/1/12-4/1/13. Out of these 8, 4 would fall under both 1/1/2012-1/1/2013 and 4/1/12-4/1/13 range. I need to be able to count ids that fall under that date range regardless if they are being counted on previous rows.

@bharukc , On of the way is

 

countrows(filter(Table, ( Table[due date] >= date(2012,1,1)  && Table[due date] < date(2013,1,1) )

|| ( Table[due date] >= date(2012,4,1)  && Table[due date] < date(2013,4,1) ) ))

 

If there date range table we need different logic

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.