cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Calculated column returning a single value based on filters from two other columns

Hello,

 

I would like to make an operation (substraction) on values from a same column and then show it on a different column.

I developped a small example for better understanding of what I'm trying to do:

 

Raw Data:

Tool #OperationStart
Tool 1A5/12/2019
Tool 1B5/14/2019
Tool 1C5/18/2019
Tool 2A5/15/2019
Tool 2B5/18/2019
Tool 2C

5/25/2019

 

What I'm trying to calculate:

Tool #Turn Around Time
Tool 16
Tool 210

 

TAT = Diff between start time of operation C and start time of operation A

 

I could work on my raw data (excel spreadsheet) directly to work this out but I wanted to know if I could do something in POWER BI directly

 

Thanks for the help

 

Sebastien

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

For your requirement, please create the measure below.

Measure =
VAR s_a =
    CALCULATE (
        MAX ( 'Table1'[Start] ),
        FILTER ( ALLEXCEPT ( 'Table1', Table1[ool #] ), 'Table1'[Operation] = "A" )
    )
VAR s_c =
    CALCULATE (
        MAX ( 'Table1'[Start] ),
        FILTER ( ALLEXCEPT ( 'Table1', Table1[ool #] ), 'Table1'[Operation] = "C" )
    )
RETURN
    DATEDIFF ( s_a, s_c, DAY )

Here is the output.

Capture.PNG

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
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

1 REPLY 1
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

For your requirement, please create the measure below.

Measure =
VAR s_a =
    CALCULATE (
        MAX ( 'Table1'[Start] ),
        FILTER ( ALLEXCEPT ( 'Table1', Table1[ool #] ), 'Table1'[Operation] = "A" )
    )
VAR s_c =
    CALCULATE (
        MAX ( 'Table1'[Start] ),
        FILTER ( ALLEXCEPT ( 'Table1', Table1[ool #] ), 'Table1'[Operation] = "C" )
    )
RETURN
    DATEDIFF ( s_a, s_c, DAY )

Here is the output.

Capture.PNG

Best Regards,

Cherry

 

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

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors