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
vibhuagwl
Frequent Visitor

Group By with where clause in DAX

Hi Team.

I am new to powerbi. I need your help. I have a below table. In this table, I would like to get the time difference between

ARGO( component)  STARTED( status) and FTS( component)  ENDED ( status) for all distinct tracking IDs( group by).

 

Screenshot 1944-11-04 at 2.42.40 PM.png

 

Thanks

Vibhu

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1674552884599.png

 

 

Time diff measure: =
IF (
    HASONEVALUE ( Data[Tracking ID] ),
    CALCULATE (
        SUM ( Data[Time] ),
        Data[Component] = "FTS",
        Data[Status] = "ENDED"
    )
        - CALCULATE (
            SUM ( Data[Time] ),
            Data[Component] = "ARGO",
            Data[Status] = "STARTED"
        )
)

 

 

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


View solution in original post

5 REPLIES 5
grazitti_sapna
Resolver I
Resolver I

Hey,

For solving this problem you can use create a new measure which will allow you to calculate the time difference between the two and get the desired output.

 

Time difference: =

IF (

    HASONEVALUE ( Data[tracking ID] ),

    CALCULATE (

        SUM ( Data[time] ),

        Data[component] = "FTS",

        Data[status] = "ENDED"

    )

        - CALCULATE (

            SUM ( Data[time] ),

            Data[component] = "ARGO",

            Data[status] = "STARTED"

        )

)

vibhuagwl
Frequent Visitor

Thanks Jhiwan for your quick response.I need one more help how to get average of "Time diff measure" for all tracking id and show in card.?

Hi,

Thank you for your message.

Please check the below whether it shows what you expected.

 

Jihwan_Kim_0-1674655792205.png

 

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


Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1674552884599.png

 

 

Time diff measure: =
IF (
    HASONEVALUE ( Data[Tracking ID] ),
    CALCULATE (
        SUM ( Data[Time] ),
        Data[Component] = "FTS",
        Data[Status] = "ENDED"
    )
        - CALCULATE (
            SUM ( Data[Time] ),
            Data[Component] = "ARGO",
            Data[Status] = "STARTED"
        )
)

 

 

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


Hi @Jihwan_Kim  thanks for your response I have one more ques. if time is coming in epoch timestamp then i am getting the wrong result. can you please help me with this.?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.