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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Rune_
Frequent Visitor

List value if conditions are true

Hi, 

 

I have a table with a column "Document No_" who has 3 lines for each document value. 

Each line has different information for that document value. 

I want to consolidate that information into only one line for each document value. 

 

Like this:

Document No_ | Value(Decimal) | Value(Date) | Valuta

D000255           | 1544                 | 06.05.2018   | null

D000259           | 480                   | 19.10.17       | AUD

 

Here is a sample of the date I have:

 

PowerQueryValuta.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

by applying this code to this table

 

image.png

 

image.png

 

 

 

you get want expected

 

 

image.png

 

View solution in original post

4 REPLIES 4
Jimmy801
Community Champion
Community Champion

Hello @Rune_ 

 

you can use Table.Pivot to solve this issue.

What I didn't get was why D000258 is not shown in your final table

Here the code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjEwMDAyNVXSUXL09Q/1C/H0c/YJcwwB8g1NTUyUYnWQlTiHBgU5+7u4AploMi6hri6OISAJAzM9A1M9IwNDC6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document No_" = _t, Code = _t, #"Value (Text)" = _t]),
    #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[Code]), "Code", "Value (Text)"),
    #"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"AMOUNTINCLVAT", type number}, {"CURRCODE", type text}, {"DUEDATE", type date}})
in
    #"Changed Type"

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

by applying this code to this table

 

image.png

 

image.png

 

 

 

you get want expected

 

 

image.png

 

Hi @Anonymous , 

This workes for the first two columns, but not the CURRCODE column. 

See before code and after code.

 

Rune__0-1597825865353.png

Rune__1-1597825984651.png

 

 

Anonymous
Not applicable

Hi @Rune_ 

to get the best possible help, you should provide tables in easy-to-copy format (not images).
You should illustrate the starting and finishing tables with meaningful examples, putting all the special cases you need to deal with.

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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