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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Pranay08
New Member

Substract columns with different data type and create a new column

Pranay08_0-1700637873607.png

These are two columns of two different tables, with different data types and i need to substract first column with the second and find out the time delay . While subtracting i need to consider date of the first column only . Is there any way to do this 

 

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, Pranay08

May I ask if this is the expected output you are looking for? Based on your description, I'm not sure which effect you want, the following diagram implements both effects.

 

Effect 1:

vyaningymsft_0-1700729533039.png

Effect 2:

vyaningymsft_1-1700729533041.png

Advanced Editor:

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc9LCsAgDEXRrYhjQV+M/WTmAgqdi/vfRikUEgU7vOQMXlrzQMQeKVF2p6BISq5ePngTPQwMkKLO1gxpgLSEWVgda0yM7T5e7tuElB1/b2B4Ywm/y/26rDExssxE7w8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date Time" = _t, #"Flight Time" = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date Time", type datetime}, {"Flight Time", type time}}),

    #"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Changed Type", {{"Date Time", type text}}, "en-US"), "Date Time", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Date Time.1", "Date Time.2"}),

    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date Time.1", type date}, {"Date Time.2", type time}}),

    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [Flight Time]-[Date Time.2]),

    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each DateTime.From([Date Time.1]) - Duration.From([Custom]))

in

    #"Added Custom1"

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
v-yaningy-msft
Community Support
Community Support

Hi, Pranay08

May I ask if this is the expected output you are looking for? Based on your description, I'm not sure which effect you want, the following diagram implements both effects.

 

Effect 1:

vyaningymsft_0-1700729533039.png

Effect 2:

vyaningymsft_1-1700729533041.png

Advanced Editor:

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc9LCsAgDEXRrYhjQV+M/WTmAgqdi/vfRikUEgU7vOQMXlrzQMQeKVF2p6BISq5ePngTPQwMkKLO1gxpgLSEWVgda0yM7T5e7tuElB1/b2B4Ywm/y/26rDExssxE7w8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date Time" = _t, #"Flight Time" = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date Time", type datetime}, {"Flight Time", type time}}),

    #"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Changed Type", {{"Date Time", type text}}, "en-US"), "Date Time", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Date Time.1", "Date Time.2"}),

    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date Time.1", type date}, {"Date Time.2", type time}}),

    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [Flight Time]-[Date Time.2]),

    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each DateTime.From([Date Time.1]) - Duration.From([Custom]))

in

    #"Added Custom1"

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.