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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ffeebr
Frequent Visitor

How to find the value in power Qerry from another row

I have the following table

Number Area  Infotipo Tp.info Amount          Firt               Last
100035  AB     40              1      1.000.000,00   04/05/2021
100035  AB     40              1      500.000,00      23/04/2021 03/05/2021
100035  AB     40               1     400.000,00      23/04/2020 22/04/2021

 

I need the value below

 

Number Area  Infotipo Tp.info Amount          Firt               Last              First Date
100035  AB     40              1      1.000.000,00   04/05/2021                      23/04/2020
100035  AB     40              1      500.000,00      23/04/2021 03/05/2021  23/04/2020
100035  AB     40               1     400.000,00      23/04/2020 22/04/2021 23/04/2020

2 REPLIES 2
ffeebr
Frequent Visitor

Dear Vejah

Thanks for your reply

There are some information that i dindt give before

The first Date should be de firt date if the the lines are consecutive.

Follow my excel 

ffeebr_0-1654611041040.png

 

Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test  (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc7NCcAgDAbQXTwL+TOtPbZriPuv0SRSD6VVMHyEPJLWEiGiaMrpvKwUtEL+MZ4lhQKM7M3U8y/QZ96mxcGwMuwCli9omV9yW9xYwaYpgsAazTsPNxxBPEyz/xsFGnsUauzpNw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Number = _t, Area = _t, Infotipo = _t, Tp.info = _t, Amount = _t, First = _t, Last = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}, {"Area", type text}, {"Infotipo", Int64.Type}, {"Tp.info", Int64.Type}, {"Amount", Int64.Type}, {"First", type date}, {"Last", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Number"}, {{"First Date", each List.Min([First]), type nullable date}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Number"}, #"Grouped Rows", {"Number"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"First Date"}, {"First Date"})
in
    #"Expanded Grouped Rows"

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors