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
Syndicate_Admin
Administrator
Administrator

Streamline log table

Good morning

I have a data record in a SQL database, which is saved as follows:

Date TypeValue
23/11/2022 14:26Registration3984XXX
23/11/2022 14:26Loading areaA
23/11/2022 14:26Loaded weight5210
23/11/2022 14:27Loaded volume7500
23/11/2022 14:27Registration2565YYY
23/11/2022 14:27Loading areaB
23/11/2022 14:27Loaded weight3680
23/11/2022 14:27Loaded volume4500
23/11/2022 14:27Registration3456KLN
23/11/2022 14:27Loading areaC
23/11/2022 14:29Loaded weight6510
23/11/2022 14:29Loaded volume8875

I try to dynamize the central column, to present the data in the desired way, and I get this:

DateRegistrationLoading areaLoaded weightLoaded volume
23/11/2022 14:263984XXXnullnullnull
23/11/2022 14:26nullAnullnull
23/11/2022 14:26nullnull5210null
23/11/2022 14:27nullnullnull7500
23/11/2022 14:272565YYYnullnullnull
23/11/2022 14:27nullBnullnull
23/11/2022 14:27nullnull3680null
23/11/2022 14:27nullnullnull4500
23/11/2022 14:273456KLNnullnullnull
23/11/2022 14:27nullCnullnull
23/11/2022 14:29nullnull6510null
23/11/2022 14:29nullnullnull8875

And I need the table like this:

RegistrationLoading areaLoaded weightLoaded volume
23/11/20223984XXXA52107500
23/11/20222565YYYB36804500
23/11/20223456KLNC65108875

I know that grouping the date by days, on other occasions, is solved, but in such a case they differ just minutes, I do not achieve a solution.

Could you help me?

Thanks a lot

5 REPLIES 5
v-jianboli-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

What do they look like? Could you please give a simple example about this?

Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-jianboli-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

Do they have some kind of logic? Or are they random? If they are random, please consider adjusting your data, otherwise it will be almost impossible to convert them into the results you want.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Each data is with its corresponding Type. Is there a way to group the data as a subset that is then transformed into a row to get the final result?

Let me explain: each transport can be characterized by these 4 parameters. Identify them as load 1, load 2, load 3, and then transform the data.

It's possible?

v-jianboli-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

Please try:

Change the day to date type - create an index column for every four rows -pivot your data

Here is the M code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdBNC4IwHMfxtyI7C7r/HpzdrG5Jh4hQxMPAYQPTsFn07puXipjmafzYl/FhRYG20ijko+PzOh4n2QwKlX6BgAQYBxACeJiugNvLg6r1zfTS6K61k8SCZlk2VaedrHRbe7JX0s5krlOV91C6Phu7GeDQ1Uaf9t41w2XkRiycbH+0wDjL83zu5S/t+o/grSVcLNbS5VpCGd+l+4XajauLHVrO3H8bO7RCRAyV5Qs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type text}, {"Type", type text}, {"Value", type text}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type1", {{"Date", type datetime}}, "en-GB"),
    #"Added Custom1" = Table.AddIndexColumn(#"Changed Type with Locale","Index",1,1),
    #"Added Custom" = Table.AddColumn(#"Added Custom1", "Custom", each Number.RoundUp([Index]/4)),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"Date", type date}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Changed Type2",{"Type", "Date", "Value"}),
    #"Added Index" = Table.AddIndexColumn(#"Removed Other Columns", "Index", 1, 1, Int64.Type),
    #"Added Custom2" = Table.AddColumn(#"Added Index", "Custom", each Number.RoundUp([Index]/4)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Index"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Type]), "Type", "Value"),
    #"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Custom"})
in
    #"Removed Columns1"

Final output:

vjianbolimsft_0-1669968109772.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you very much for your very detailed answer.

I have an extra problem: not all records are correct, there are incomplete orders that do not have the 4 data, and there are some that are not in that order.

Would you have a solution?

Thanks a lot

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.