Lädt...


🔧 #71 — Take Values of Adjacent Rows in The Same Group (Search & Filter within Adjacent Intervals)


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Problem description & analysis:

There is an Excel table:

source table
Task: Now we want to add two columns, PreviousDailySales and NextDailySales, to fill in the sales of current product on the previous selling day and the next selling day, respectively.

Analysis: The data is sorted by date first, and then by product. If the rows with same product are regarded as a group, the problem will change to taking the values of the previous row and the next row in the same group. The difficulty of the problem is how to find the previous and next rows in the same group without changing the order of rows.

Solution:

There are two ideas to solve this problem (fill in the code in cell D1):
1. Search and filter in adjacent intervals: directly search forward and backward without changing the order of data. Once the row of the first product with the same name is found, it is the sales of the previous selling day/next selling day.

     A
 1  =E(‘A1:C2401’)
 2  =A1.derive(~[:-1].select@1z(ProductName==A1.ProductName).Sales:PreviousDailySales, ~[1:].select@1(ProductName==A1.ProductName).Sales:NextDailySales)
 3  return A2.new(PreviousDailySales,NextDailySales)

A2: ~[:-1] represents the set of all rows from the beginning to the previous row, and ~[1:] represents the set of all rows from the next row to the end.

2. Take the value of adjacent rows within the same group: group the data by product, and take the value of the previous row/the next row within the group directly, which is the sales of the previous selling day/next selling day.

     A
 1  =E(‘A1:C2401’).derive(:PreviousDailySales,:NextDailySales)
 2  =A1.group(ProductName).run(~.run(PreviousDailySales=Sales[-1], NextDailySales=Sales[1]))
 3  return A1.new(PreviousDailySales,NextDailySales)

A2: Sales[-1] represents the value of column Sales of the previous row, Sales[1] represents the value of column Sales of the next row.

The result is shown in the picture below:

result table

Feel free to download esProc Desktop for FREE and Master advanced filtering techniques in no time!! 🚀🔥⬇️

✨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

...

🔧 #71 — Take Values of Adjacent Rows in The Same Group (Search & Filter within Adjacent Intervals)


📈 146.75 Punkte
🔧 Programmierung

🔧 Sorting Rows with Empty Values at the Bottom and Non-Empty Values in Descending Order in Laravel


📈 44.37 Punkte
🔧 Programmierung

🔧 #70 — Search by Adjacent Rows


📈 44.3 Punkte
🔧 Programmierung

🔧 #49 - Group An EXCEL Table And Concatenate Values of Rows Meeting The Specified Condition


📈 37.82 Punkte
🔧 Programmierung

🔧 #44 — Group Rows And Combine Non-Null Values in Each of The Non-Grouping Columns


📈 37.82 Punkte
🔧 Programmierung

🔧 #41 — Group And Summarize Rows While Retaining Columns Whose Values Are Unchanged


📈 37.82 Punkte
🔧 Programmierung

🔧 Group Rows and Concatenate Cell Values


📈 37.82 Punkte
🔧 Programmierung

🔧 Group Rows and Concatenate Cell Values


📈 37.82 Punkte
🔧 Programmierung

🔧 Pandas Count Rows – How to Get the Number of Rows in a Dataframe


📈 36.6 Punkte
🔧 Programmierung

🔧 Có thể bạn chưa biết (Phần 1)


📈 34.7 Punkte
🔧 Programmierung

🔧 Tìm Hiểu Về RAG: Công Nghệ Đột Phá Đang "Làm Mưa Làm Gió" Trong Thế Giới Chatbot


📈 34.7 Punkte
🔧 Programmierung

🔧 #74 - Filter by Maximum Or Minimum Value within A Group (Find out One for Each Group)


📈 32.58 Punkte
🔧 Programmierung

🔧 #64 — Search for Top N Values And Last N Values


📈 31.89 Punkte
🔧 Programmierung

🔧 #79 - Split Aggregation Values And Fill Them in Detail Rows


📈 31.33 Punkte
🔧 Programmierung

🔧 #54 - Combine Cell Values of Every 3 Rows under Each Column into One Cell


📈 31.33 Punkte
🔧 Programmierung

🔧 In Excel, Insert Group Headers to Detail Data Rows in Each Group


📈 31.27 Punkte
🔧 Programmierung

🎥 re:publica 2024: „Chatkontrolle“ – Same same, but different, but still same?


📈 30.38 Punkte
🎥 Video | Youtube

🔧 #89 — Calculate Proportion Using the Aggregation Values of the Data from the Same Group


📈 29.65 Punkte
🔧 Programmierung

🔧 #56 — Get The Same Rows from A Table


📈 28.43 Punkte
🔧 Programmierung

🔧 How to Split Attributes of Same Type in One Row and Convert Them into Multiple Rows


📈 28.43 Punkte
🔧 Programmierung

🔧 #66 — Search for The Position of A Certain Value And Take Values by Position


📈 26.34 Punkte
🔧 Programmierung

🔧 Missing Values in R — remove na values


📈 26.07 Punkte
🔧 Programmierung

🔧 JavaScript Primitive Values vs Reference Values – Explained with Examples


📈 26.07 Punkte
🔧 Programmierung

🐧 GetSet-Values, a tool to import/export values from config files into a script


📈 26.07 Punkte
🐧 Linux Tipps

🐧 Pandas – Convert Categorical Values to Int Values


📈 26.07 Punkte
🐧 Linux Tipps

📰 Temperature Scaling and Beam Search Text Generation in LLMs, for the ML-Adjacent


📈 26 Punkte
🔧 AI Nachrichten

🔧 #59 - Split IP Addresses And Then Group Rows


📈 24.79 Punkte
🔧 Programmierung

🔧 #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order


📈 24.79 Punkte
🔧 Programmierung

🔧 #50 — Group And Summarize Rows And Add Different Words After Different Counts


📈 24.79 Punkte
🔧 Programmierung

🔧 #27 — Group and Summarize A Table Where Every N Rows Consists of A Range by Column


📈 24.79 Punkte
🔧 Programmierung

matomo