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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Dax to get the count more than 15 days

Hi! 

Does anyone know how can I get the count for more than 15 days using the DATETIME and CountItem column? This is my current measure, I am not sure if this is the correct one. 

 

Count_Morethan15Days = Calculate ( [CountItem] , DateDiff ( 'Table2'[DATETIME] , Now() , DAY ) >= 15 )

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I think 'Table2'[DATETIME] should be in datetime data type. I suggest you to calculate the datediff based on hour instead of day. For example, in my sample ItemD has 1/16/2023 9:00:00 PM and now is 1/31/2023 5:21:00 PM. So datediff for ItemD is less than 15 days. The correct count should be 3, however your measure will return 4.

RicoZhou_1-1675156822472.png

Please make sure both [CountItem] and [Count_Morethan15Days] should be measures.

CountItem = CALCULATE(COUNT(Table2[Item]))
Count_Morethan15Days = Calculate ( [CountItem] ,DateDiff ( 'Table2'[DATETIME] , Now() , HOUR )/24 >= 15 )

Result is as below.

RicoZhou_2-1675157022690.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

I think 'Table2'[DATETIME] should be in datetime data type. I suggest you to calculate the datediff based on hour instead of day. For example, in my sample ItemD has 1/16/2023 9:00:00 PM and now is 1/31/2023 5:21:00 PM. So datediff for ItemD is less than 15 days. The correct count should be 3, however your measure will return 4.

RicoZhou_1-1675156822472.png

Please make sure both [CountItem] and [Count_Morethan15Days] should be measures.

CountItem = CALCULATE(COUNT(Table2[Item]))
Count_Morethan15Days = Calculate ( [CountItem] ,DateDiff ( 'Table2'[DATETIME] , Now() , HOUR )/24 >= 15 )

Result is as below.

RicoZhou_2-1675157022690.png

 

Best Regards,
Rico Zhou

 

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

 

ribisht17
Super User
Super User

@Anonymous 

ribisht17_0-1674812927155.png

 

Count Distinct Items < 15 = CALCULATE(DISTINCTCOUNT(Items[Item]),
                       all(Items),DATEDIFF(Items[Date],TODAY(),DAY) < 15)
 
Regards,
Ritesh

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.