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
ovetteabejuela
Impactful Individual
Impactful Individual

Convert Field of Time Type During Data Refresh

Hi,

 

I just wanted to know how to do this during "Get Data".

 

What I am doing:

 

1. Upload this table to PowerBI:

date_transdur_scheduled
12/1/20169:00
12/2/20169:00
12/3/20160:00
12/4/20160:00
12/5/20169:00
12/6/20169:00
12/7/20169:00
12/8/20169:00
12/9/20169:00
12/10/20160:00

 

2. I wanted to do an aggregate so I did (and I have no problem with the code, it's aggregating as expected):

Duration Schedule Aggregate = SUMX(tablename,tablename[dur_scheduled]) * 24

3. Basically I don't want to do this for every field that is of time type so the question is:

Can I do this during "Edit Queries" --- multiply the time by 24 the same way as the code above.\

 

Thank you.

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

Hi @ovetteabejuela

If you mean that multiply the time field by 24 before loading data into Power BI, from my point of view, you would need to implement the process in  your source.

However, if you want to implement the multiplication for multiple time type field in Query Editor, to simplify the process,  you can create a parameter in Query Editor as shown in the first screenshot, change the type of your time field to Decimal number, then add a custom column as shown in the second screenshot.
1.PNG2.PNG3.PNG

The above steps generate bold part of the following code in Advanced Editor, you can add these codes (replace dur_scheduled with other field names) into Advanced Editor of different queries based on your needs.

let
    Source = Excel.Workbook(File.Contents("path\New Microsoft Excel Worksheet (3).xlsx"), null, true),
    Table2_Table = Source{[Item="Table2",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Table2_Table,{{"dur_scheduled", type time}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"dur_scheduled", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [dur_scheduled]*Para),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type number}})
in
    #"Changed Type2"


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
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-yuezhe-msft
Employee
Employee

Hi @ovetteabejuela

If you mean that multiply the time field by 24 before loading data into Power BI, from my point of view, you would need to implement the process in  your source.

However, if you want to implement the multiplication for multiple time type field in Query Editor, to simplify the process,  you can create a parameter in Query Editor as shown in the first screenshot, change the type of your time field to Decimal number, then add a custom column as shown in the second screenshot.
1.PNG2.PNG3.PNG

The above steps generate bold part of the following code in Advanced Editor, you can add these codes (replace dur_scheduled with other field names) into Advanced Editor of different queries based on your needs.

let
    Source = Excel.Workbook(File.Contents("path\New Microsoft Excel Worksheet (3).xlsx"), null, true),
    Table2_Table = Source{[Item="Table2",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Table2_Table,{{"dur_scheduled", type time}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"dur_scheduled", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [dur_scheduled]*Para),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type number}})
in
    #"Changed Type2"


Thanks,
Lydia Zhang

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

 

Spoiler
"If you mean that multiply the time field by 24 before loading data into Power BI, from my point of view, you would need to implement the process in  your source."

 We'll this is actually an option an I think you mean to pass on the workload to the source, but what I was trying to get rid of is additional manual interference on the existing process.. I will also revisit the process on acquiring the data.

 

Thanks a lot for the help @v-yuezhe-msft

 

[EDIT] ...and of course your solution works! thanks.

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.