Date query in Powerquery

ErsinALACA

New Member
Joined
Mar 6, 2020
Messages
31
Office Version
  1. 2019
Platform
  1. Windows
Sorry my english is not enough. I will explain it simply;

TableA;
TableA.PNG


TableB (Wanted)
TableB.PNG


Thanks for answers.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
If I can, I prefer it too. I'm sorry, I have no information. Let's wait, maybe another friend can suggest a solution
 
Last edited:
Upvote 0
not optimised to single query yet, I am too lazy ? :devilish:?

Code:
// Table2
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content]
in
    Source

// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content]
in
    Source

// Merge1
let
    Source = Table.NestedJoin(Table2,{"Date"},Table1,{"Date"},"Table1",JoinKind.FullOuter),
    Expand = Table.ExpandTableColumn(Source, "Table1", {"Date", "Part", "Price"}, {"Date.1", "Part", "Price"}),
    Conditions = Table.AddColumn(Expand, "Custom", each if [Date] = null then [Date.1] else [Date]),
    Sort = Table.Sort(Conditions,{{"Custom", Order.Ascending}}),
    TSC = Table.SelectColumns(Sort,{"Custom", "Part", "Price"}),
    FillD = Table.FillDown(TSC,{"Part", "Price"}),
    FillU = Table.FillUp(FillD,{"Part", "Price"})
in
    FillU

// Merge2
let
    Source = Table.NestedJoin(Table2,{"Date"},Merge1,{"Custom"},"Merge1",JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Source, "Merge1", {"Part", "Price"}, {"Part", "Price"}),
    Distinct = Table.Distinct(Expand),
    Type = Table.TransformColumnTypes(Distinct,{{"Date", type date}})
in
    Type
Table1Table2Merge2
DatePartPriceDateDatePartPrice
02/03/2020Part1320/03/202020/03/2020Part49
02/03/2020Part2528/03/202028/03/2020Part511
05/03/2020Part37
09/03/2020Part49
25/03/2020Part511
25/03/2020Part613
31/03/2020Part719
 
Upvote 0
Sevgili sandy666; tebrikler. (y)

Part1, Part2, Part3 ... When partn parts are sold at Table1 on the same date, can we see all parts prices as unique value?
 
Upvote 0
you didn't say that in the "first" post where should be detailed description
so just test it

I did approximate match only
 
Upvote 0
Understood. In the table I sent in # 26, there are two different parts prices on each date. I wanted to see them if there were two or more. No need if it's hard. I wanted to take examples for more difficult queries.
 
Upvote 0
combine the right pieces of code and try to do it yourself. I can't do everything as ready-made-solution.

maybe tomorrow or later I'll think about it
 
Upvote 0
Same to you. I hope one day he learns PowerQuery as much as you do and I can help other friends too here.
 
Upvote 0

Forum statistics

Threads
1,223,803
Messages
6,174,687
Members
452,577
Latest member
Filipzgela

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top