1,495 questions
0
votes
1
answer
48
views
Calculating running total according to multiply groups in Power BI
I need to calculate the total number of piglets born per year and quarter, grouped by cycle. The cycle can range from 1 to 9. So I would like to see this: enter image description here There are some ...
3
votes
2
answers
84
views
Distribute value to fill and unfill a Polars column based on a given condition
The problem:
I want to distribute a value that can be positive or negative from one row into multiple rows, where each row can only contain a specific amount, if the value to distribute is positive it ...
0
votes
0
answers
52
views
Runnin totals does not respect sort of data
I'm trying to calculate running totals of my data, but when I change the order of the rows the field does not change to respect the sequence of data
It seems that they are calculated based on original ...
4
votes
1
answer
110
views
Polars cumulative count over sequential dates
Here's some sample data
import polars as pl
df = pl.DataFrame(
{
"date": [
"2024-08-01",
"2024-08-02",
"2024-08-03&...
0
votes
2
answers
64
views
Cumulative budget that skips entries that exceed budget
I have a column of item costs listed top-down in order of priority that I need to purchase with $100. I would like to be able to maximize my $100 while maintaining my priority purchases as much as ...
6
votes
1
answer
7k
views
Polars cumulative sum over consecutive groups
I have a DataFrame like so:
import polars as pl
df = pl.from_repr("""
┌────────────┬───────┬───────┐
│ Date ┆ Group ┆ Value │
│ --- ┆ --- ┆ --- │
│ date ┆ i64 ┆...
1
vote
1
answer
76
views
SQL Query in Snowflake - Calculate Days of Supply
I tried to find the days of supply each day. For example, date 1/23/2025 - It has inventory 700 which already subtract the forecast, 400 on that day. Count how many date of forecast can be covered by ...
1
vote
2
answers
92
views
How can I count repeats in a a column but reset count on non-repeats, in an array formula
I have data like this where there's just two words I need to check at any time.
I cant figure out how to count the duplicates but break the counting if there is another value inbetween.
Column A
...
0
votes
1
answer
51
views
Cumulative Measure Flatlines After Current Date
I am visualizing the % Completion for a project. The visual I've created shows two data series - one for actual % complete (Cumulative_Complete) and another for the planned % complete. The plan series ...
0
votes
2
answers
227
views
Calculate a running 7-day total in LibreOffice Calc, where dates may have multiple entries
How do I write a formula that I can copy and paste into a column in a LibreOffice Calc spreadsheet so that each cell displays a running 7-day total of the values in a different column. Column A ...
-4
votes
1
answer
156
views
How to partition into batch of records with max batch size limit
I want to batch the students into maximum batch size of 100, partitioned by School.
Each teacher can have 12 students.
Students of any teacher should not be split into different batches.
No. of ...
0
votes
2
answers
3k
views
Cumulative Sum in ClickHouse
I have clickhouse table with 3 columns: respondent, spot и weight.
Data looks like this:
resp, spot, weight
1, 10, 100
2, 10, 200
3, 10, 300
1, 10, 100
1, 20, 100
3, 20, 300
4, 20, 400
1, 30, 100
2, ...
1
vote
1
answer
114
views
Running total (cumulative sum) optimization
I have to use running total value for the parameter "users". Here is the script (simplified):
with us_data as (
select
count(us.*) as us_reg,
count(us.*) filter (where status =...
92
votes
9
answers
147k
views
Create a Cumulative Sum Column in MySQL
I have a table that looks like this:
id count
1 100
2 50
3 10
I want to add a new column called cumulative_sum, so the table would look like this:
id count cumulative_sum
1 100 ...
60
votes
6
answers
104k
views
Calculate running total / running balance
I have a table:
create table Transactions(Tid int, amt int)
With 5 rows:
insert into Transactions (Tid, amt)
values
(1, 100),
(2, -50),
(3, 100),
(4, -100),
(5, 200);
Desired output:
TID amt ...
1
vote
5
answers
145
views
calculate cumulative sum over month and by group as well
I first calculated monthly sum by counting IDs within a group using group-by and mutate. However, as I try to use cumsum to calculate monthly cumulative sum by group using cumsum, the data just does ...
4
votes
1
answer
154
views
Bottom-up tree structure cumulative sum
CREATE TABLE Emissions (
entityId VARCHAR(512),
parentId VARCHAR(512),
emission DECIMAL,
percentContribution VARCHAR(512)
);
INSERT INTO Emissions (entityId, parentId, ...
-1
votes
2
answers
94
views
Automate Formula | Excel [closed]
I have quite a complex formula issue that I am trying to fix with excel, not sure if it's possible.
Basically what I want to do is the following for my total treated patients by Product I want to do ...
1
vote
1
answer
150
views
Distinct cumulative count in PostgreSQL window function
I've got a table with many columns some of these are:
product_id, territory_id, quarter_num (it's a number of a quarter from 1 to 28 for instance).
There are some other columns but they aren't ...
1
vote
1
answer
123
views
Rolling cumulative product over aggregated data in PySpark
In the following PySpark dataframe I am trying to multiply values in column top to bottom (as if I was using F.product function) but instead of row by row calculation I have subgroups of identical ...
1
vote
2
answers
196
views
Excel Summing a chart Based on Month
Above is a chart I am trying to sum based on the month. Ie I want a running total that I don't have to adjust as each month changes. I know it may look a little strange but the fiscal year for us goes ...
0
votes
2
answers
60
views
Calculated column in SQL based on multiple column matches between two tables and cumsum
Calculated column in SQL based on multiple column matches and cumsum between two tables
I have two tables.
Table 1: has 4 columns as shown below.
X
Y
A( in days)
B(sum)
a
aa
7
a
bb
9
b
aa
36
c
dd
29
...
0
votes
2
answers
65
views
Weighted hierarchical cumulative sum
I don't know if I'm using the correct terminology, but I'm trying to find the cumulative sum of each node in a tree structure, but the children node only contribute a percentage of its cumulative sum ...
-2
votes
1
answer
44
views
End month balance and calculate supportable
I tried looking for some solution here, but still stuck.
WITH MyData AS (
SELECT 'Jun 2024' AS [date], 'A' AS [group], 69 AS Supply, 0 AS Forecast
UNION ALL SELECT 'Jul 2024', 'A', 61, 0
...
0
votes
4
answers
99
views
rolling sum with conditions
I have a dataset like:
ID DATETIME CODE Value
999 1/2/2024 16:22 TX 100
123 1/2/2024 16:47 IP 100
666 1/2/2024 17:13 IP 85
666 1/2/2024 17:38 IP 100
123 1/2/2024 18:03 ...