• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Special VlookUp|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Special VlookUp|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QuerySpecial VlookUp
sp_PrintTopic sp_TopicIcon
Special VlookUp
Avatar
farshad mansourian
Member
Members
Level 0
Forum Posts: 9
Member Since:
March 13, 2022
sp_UserOfflineSmall Offline
1
March 15, 2022 - 4:39 am
sp_Permalink sp_Print

Hello . Your site is very useful. We have two ranges in the attachment. In the first range, the four columns are completely full and in the second range, the last column is empty. What is the 9000 number recognition algorithm? The p .Code & SRC columns are exactly equal, and we need to move the corresponding rate to the second range after finding the date that is less than or equal to the date in the first range, as you can see in the example.
(Here is the solar date or Persian and the "/" sign is removed from the year, month and day to be numbered [Explanation: Microsoft Office does not support solar date]). I want this issue to be resolved using PowerQuery. Because I can do it in VBA

sp_AnswersTopicSeeAnswer See Answer
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 442
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
March 15, 2022 - 5:41 pm
sp_Permalink sp_Print

If you have Excel for MS365 or 2021 you can fairly easily use a formula based solution with INDEX and XMATCH. But, you explicitly asked for a PQ based solution. The attached file contains both. See which one works best for you.

sp_AnswersTopicAnswer
Answers Post
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4450
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
3
March 15, 2022 - 8:11 pm
sp_Permalink sp_Print

Hi Riny,

Thanks for helping out. Please try uploading your file again. You need to click the 'Start Upload' button after selecting your file, then wait for the grey check mark beside the file size before clicking the Submit Reply button.

Thanks,

Mynda

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 442
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
4
March 15, 2022 - 8:28 pm
sp_Permalink sp_Print

Thanks Mynda for pointing that out. Must have missed that last click.

Trying again.

The following users say thank you to Riny van Eekelen for this useful post:

Mynda Treacy
Avatar
farshad mansourian
Member
Members
Level 0
Forum Posts: 9
Member Since:
March 13, 2022
sp_UserOfflineSmall Offline
5
March 16, 2022 - 1:39 am
sp_Permalink sp_Print sp_EditHistory

Hello again . Thank you very much for your reply, Mr. Riny van Eekelen. And of course the site staff who have provided this opportunity.I may not have used the right words to say thank you. I use Google Translator to write 

I wanted to ask members to write other ways to solve the problem

Avatar
farshad mansourian
Member
Members
Level 0
Forum Posts: 9
Member Since:
March 13, 2022
sp_UserOfflineSmall Offline
6
April 13, 2022 - 8:54 pm
sp_Permalink sp_Print sp_EditHistory

The following code is exactly what I wanted. A friend like Mr. Riny van Eekelen helped me get this code

 

let

//Read in the lookup table
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
lookupTable = Table.TransformColumnTypes(Source,{
{"Date", Int64.Type},
{"P.Code",Int64.Type},
{"SRC", Int64.Type},
{"Rate", Int64.Type}
}),

//read in data table
Source2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
typeIt2 = Table.TransformColumnTypes(Source2,{
{"Date", Int64.Type},
{"P.Code", Int64.Type},
{"SRC", Int64.Type}
}),

//Join the two tables based on PCode and Src
join = Table.NestedJoin(typeIt2,{"P.Code","SRC"},lookupTable,{"P.Code","SRC"},"Joined", JoinKind.LeftOuter),

//for each joined subtable
// Sort descending
// Select only those rows where the date in table 2 is >= the corresponding date from table 1
// Then extract the first row Rate value (as that will be the closest to the date in table 2)
#"Added Custom" = Table.AddColumn(join, "Rate1", each Table.SelectRows(Table.Sort([Joined],
{"Date",Order.Descending}),(t)=> t[Date] <= [Date])[Rate]{0}, Int64.Type),

//Remove unneeded join table column
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Joined"})

in
#"Removed Columns"

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Brian Pham
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.