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
frankhofmans
Helper IV
Helper IV

Combine multiple columns

hi PBI community,

 

i have the following data table (> 300.000 rows):

 

Client IDTaskAmountInv. Nr 1Date inv. Nr 1Inv. Nr 2Date inv. Nr 2
a001intake30I20220011-1-2021blankblank
a001contact20I20220011-1-2021blankblank
a001consult100I20220011-1-2021blankblank
a001contact-20I20220011-1-2021I20220021-2-2021
a001intake30I20220021-2-2021blankblank

 

When a task isn't credited, the colums Inv. nr 2 is blank. When a task is credited, the number of the new invoice is filled in in colums Inv. nr 2 and the amount changes to a negative number. In this case, whe originally send a invoice (Inv. nr I2022001) with an amount of EUR 150 and a new invoice (I2022002) with an amount of EUR 10 (EUR 30 and the credited EUR -20). Is there a possibility to merge or expand the colums to get 1 column with the right invoice number?

 

Many thanks in advance,

 

Regards,

 

Frank

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @frankhofmans 

 

So is it what you want? Added new column instead of tranforming the original

Vera_33_0-1649681350895.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSjQwMFTSUcrMK0nMTgUyjA2AhKeRgZERRMLAUB+IgHwQJyknMS8bTsfqwLUn5wP1J5cAWUbk6i8uzQHpNzSg0AG6eF0AFTeCihtBxJEMwhoQaMox3BELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Client ID" = _t, Task = _t, Amount = _t, #"Inv. Nr 1" = _t, #"Date inv. Nr 1" = _t, #"Inv. Nr 2" = _t, #"Date inv. Nr 2" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Inv", each if [Inv. Nr 2]="blank" then [Inv. Nr 1] else [Inv. Nr 2]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Date", each if [Date inv. Nr 2] ="blank" then [Date inv. Nr 1] else [Date inv. Nr 2]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Date", type date}, {"Amount", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Inv. Nr 1", "Date inv. Nr 1", "Inv. Nr 2", "Date inv. Nr 2"})
in
    #"Removed Columns"

 

View solution in original post

1 REPLY 1
Vera_33
Resident Rockstar
Resident Rockstar

Hi @frankhofmans 

 

So is it what you want? Added new column instead of tranforming the original

Vera_33_0-1649681350895.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSjQwMFTSUcrMK0nMTgUyjA2AhKeRgZERRMLAUB+IgHwQJyknMS8bTsfqwLUn5wP1J5cAWUbk6i8uzQHpNzSg0AG6eF0AFTeCihtBxJEMwhoQaMox3BELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Client ID" = _t, Task = _t, Amount = _t, #"Inv. Nr 1" = _t, #"Date inv. Nr 1" = _t, #"Inv. Nr 2" = _t, #"Date inv. Nr 2" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Inv", each if [Inv. Nr 2]="blank" then [Inv. Nr 1] else [Inv. Nr 2]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Date", each if [Date inv. Nr 2] ="blank" then [Date inv. Nr 1] else [Date inv. Nr 2]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Date", type date}, {"Amount", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Inv. Nr 1", "Date inv. Nr 1", "Inv. Nr 2", "Date inv. Nr 2"})
in
    #"Removed Columns"

 

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.