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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sagar512
Helper I
Helper I

Count Rows Falling between two dates ( from disconnected table )

Hi,

I am having two disconnected tables ( Task and Ticket).

On Task Table I need to count tickets (from the Ticket table) that fall between the task created date and Created +90 date.

 

In Excel, I used the below formula to get the expected output.

 

how can calculate the same in dax?

 

sagar512_0-1640078796207.png

 

Task Table
Task NumberCreatedCreated +90
Task 11-Jan-211-Apr-21
Task 21-May-2130-Jul-21
Task 31-Sep-2130-Nov-21
Task 41-Jun-2130-Aug-21
Task 51-Dec-211-Mar-22

 

 

 

Ticket Table
Ticket NumberCreated
Ticket 17-Jan-21
Ticket 22-Feb-21
Ticket 32-Feb-21
Ticket 46-Jun-21
Ticket 510-Jun-21
Ticket 619-Aug-21
Ticket 79-Sep-21
Ticket 813-Jun-21
Ticket 93-Mar-21
Ticket 109-Sep-21

 

 

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

Resolved here 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
smpa01
Super User
Super User

Resolved here 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

Expected Output: =
IF (
HASONEVALUE ( Task[Task Number] ),
COALESCE (
CALCULATE (
COUNTROWS ( Ticket ),
Ticket[Created] >= MAX ( Task[Created] )
&& Ticket[Created] <= MAX ( Task[Created +90] )
),
0
)
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


thanks, but the problem with the above solution is I need to always keep the lowest level (Task number) into the context.


my end goal is to build some chart that aggregates to month level etc, but calculation should always stay at task number level and then aggregate.

I think the column was the best fit in this scenario but unfortunately, I can't use it due to direct query. (cant use calculate and x functions)  😞

amitchandak
Super User
Super User

@sagar512 , A new column in table 1

 

countx(filter(ticket, ticket[created]>= task[Created] && ticket[created]<= task[Created+90]) ,ticket[Ticket Number] )

 

the measure would be very similar to what we have here, but need to ticket in place of date

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

Hi,

Thanks for the response;

but since these are two different tables I don't get the task created date under the filter function

sagar512_0-1640082569257.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.