Logo

dev-resources.site

for different kinds of informations.

#131 — Use Association Table to Handle Interval Association

Published at
1/15/2025
Categories
programming
beginners
tutorial
productivity
Author
judith677
Author
9 person written this
judith677
open
#131 — Use Association Table to Handle Interval Association

Example 1:

Problem description & analysis:
Here below is a data table:

sheet 2

sheet 1

Task: Calculate the values in column B of Sheet2 according to the rule: search Sheet1 with the quantity value of Sheet2, if the value is greater than StartQuantity and less than or equal to EndQuantity of a certain row, return the price of this row.

Solution:

To achieve this task, use SPL XLL and enter the following code in cell B2:

=spl("=E(?1).segp@r(StartQuantity,?2).Price",Sheet1!A$1:C$5,A2)
Enter fullscreen mode Exit fullscreen mode

result

Then drag B2 down to every relevant row:

result table
Code explanation:

The idea of the calculation is to use the segp function to query which segment number of interval formed by StartQuantity of Sheet1 the quantity value is in, and then take the price of the row corresponding to the segment number and return. The option @r means forming a left-open and right-closed interval. For example, the number 50 should be counted in the interval where the first row is located.

Example 2:

Problem description & analysis:
Here below is a car charging data table:

sheet 3

The following table lists the electricity price data at different charging time intervals:

sheet 4

Task: Calculate the values in Price column of Sheet3 according to the rule: search Sheet4 for the time interval where the hour number of Starttime is located, and take the price.

Solution:
To achieve this, use SPL XLL and enter the following code in cell E2:

=spl("=a=E@b(?1),a(3).array().to(2,)(a(1).array().to(2,).pseg(?2))", Sheet4!A$1:F$3, HOUR(B2))
Enter fullscreen mode Exit fullscreen mode

result

Drag E2 down to every relevant row:

result table

Code explanation:

The idea of calculation is to use the StartHour sequence starting from the 1st row and the 2nd column of Sheet4 to form the time intervals, and search for the interval where the hour number of Starttime of Sheet3 is located, and take the price in the corresponding 3rd row of Sheet4 and return.


Download esProc Desktop for FREE and revolutionize your Excel processes using SPL XLL!! 🚀✨⬇️

✨SPL download address: esProc Desktop FREE Download

✨Plugin Installation Method: SPL XLL Installation and Configuration

✨References to other rich Excel operation cases: Desktop and Excel Data Processing Cases

✨YouTube FREE courses: SPL Programming

productivity Article's
30 articles in total
Productivity tools and practices enhance efficiency and help individuals and teams achieve more in less time.
Favicon
🚨 The Dangers of Developers Relying Exclusively on AI Without Understanding Fundamental Concepts
Favicon
🕒 What’s your most productive time of the day?
Favicon
The Career Killer Checklist: 10 Common Pitfalls to Avoid in 2025
Favicon
⚖️FROM Burn-Out TO Balance-Out (2/4)
Favicon
5 Free AI Design Tools For Designers!
Favicon
Vinny built CoverletterGPT to $500/month, a good read
Favicon
➡️💡Guide, Innovate, Succeed: Becoming a Software Development Leader 🚀
Favicon
🚀 New Book Release: "Navigate the Automation Seas" – A Practical Guide to Building Automation Frameworks
Favicon
Top 10 Web3 Careers for Success: Part 1
Favicon
got Tired of analysis paralyysis so i built an extensioon to get into flow faster
Favicon
Make Better Decisions as a Software Engineer Using the Pugh Matrix
Favicon
[Free Tool] I made an AI-powered content generator for RedNoteApp/Xiaohongshu
Favicon
5 Tools Every Developer Should Know in 2025
Favicon
The Perils of Presumption: Why Making Assumptions in Development is Bad
Favicon
[Boost]
Favicon
#131 — Use Association Table to Handle Interval Association
Favicon
How Project Time Tracking Can Enhance Budget Management and Resource Allocation
Favicon
Building An SAAS in 2025-Week 1
Favicon
[Boost]
Favicon
[Boost]
Favicon
🎁 20 Open Source Projects You Shouldn't Miss in 2025
Favicon
🌐 Embracing the Future: Cryptocurrency, Blockchain, and AI Synergy 🌐
Favicon
Ctrl Yourself! VS Code Shortcuts🎛️
Favicon
Top 50 Websites a Backend Developer Must Know 🖥️🔧🚀
Favicon
Unlocking the Power of GitHub Copilot: Your AI Pair Programmer
Favicon
Moving Apple Music MP3 Playlists To Android
Favicon
Digital Warm Up
Favicon
💡 How Do You Generate Your Cover Images for Blog Posts?
Favicon
What would you say are going to be the Top Trending Topics this 2025?
Favicon
Procrastinator’s Guide to Glory: Turning Wasted Time Into Career Gold with Open Source

Featured ones: