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
equlibrum96
New Member

Filtering by iterator in calculated column

Hello everyone

Hello, I am a young PowerBi adept and I need help in calculating a new calculated column 

 

My data looks like this: I have a case table, a calls table, and the so-called bridge tables combining case and calls (case_calls)

 

case table

 

case_idfirst_contact_date
first_call_date_after first_contact
107-10-20239-10-2023
208-10-202310-10-2023

 

case_calls table

case_idcall_id
1a
1b
1c
2d
2e

 

calls table

 

call_idcall_datestatus
a6-10-2023picked up
b8-10-2023missed
c9-10-2023picked up
d5-10-2023picked up
e10-10-2023picked up

 

 

My need is to calculate the first_call_date_after first_contact column in case table (marked in red)

 

The definition of this column is the date of the first related call for which:
1) call_date>= first_contact_date AND status= "picked up"

 

In other words, for each case_id in the case table, I want to calculate the date of the first picked up calls (status = "picked up") after the date of the first contact (first_contact_date)

 

 

I would be very grateful for your help 🙂 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @equlibrum96 

 

You can try the following methods.

Measure = 
CALCULATE ( MIN ( 'calls table'[call_date] ),
    FILTER ( ALL ( 'calls table' ),
        [status] = "picked up"
            && [call_date] > MAX ( 'case table'[first_contact_date] )
            && RELATED ( 'case_calls table'[call_id] ) = MAX ( 'calls table'[call_id] )
    )
)

vzhangti_0-1697104984363.png

Column = CALCULATE ( MIN ( 'calls table'[call_date] ),
    FILTER ( 'calls table' ,
        [status] = "picked up"
            && [call_date] > EARLIER( 'case table'[first_contact_date] )
            && RELATED ( 'case_calls table'[case_id] ) = EARLIER('case table'[case_id])
    )
)

vzhangti_1-1697105120166.png

Is this the result you expect?

 

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @equlibrum96 

 

You can try the following methods.

Measure = 
CALCULATE ( MIN ( 'calls table'[call_date] ),
    FILTER ( ALL ( 'calls table' ),
        [status] = "picked up"
            && [call_date] > MAX ( 'case table'[first_contact_date] )
            && RELATED ( 'case_calls table'[call_id] ) = MAX ( 'calls table'[call_id] )
    )
)

vzhangti_0-1697104984363.png

Column = CALCULATE ( MIN ( 'calls table'[call_date] ),
    FILTER ( 'calls table' ,
        [status] = "picked up"
            && [call_date] > EARLIER( 'case table'[first_contact_date] )
            && RELATED ( 'case_calls table'[case_id] ) = EARLIER('case table'[case_id])
    )
)

vzhangti_1-1697105120166.png

Is this the result you expect?

 

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.

tamerj1
Super User
Super User

Hi @equlibrum96 

Please try

first_call_date_after first_contact =
MINX (
FILTER (
CALCULATETABLE ( Calls, TREATAS ( { Case[Case_Id] }, Case_Calls[Case_Id] ) ),
Calls[Call_Date] > Case[First_Contact_Date]
&& Calls[Status] = "Picked Up"
),
Calls[Call_Date]
)

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.