2,390 questions
0
votes
0
answers
57
views
PostgreSQL database, querying on column name [closed]
I need to use column name to find month name
transaction_period_01="January"
transaction_period_01="February"
like this
SELECT
"TR_FI_GL_BALANCE".fiscal_year,
...
1
vote
2
answers
146
views
Clustered columnstore index with computed column -- why does segment elimination not work?
Recent versions of Microsoft SQL Server allow creating a clustered columnstore index on a table that has computed columns, as long as they are not persisted computed columns. [1]
I would like to get ...
-1
votes
1
answer
67
views
ASP.NET Core MVC : where in the controller to put the calculation of day difference, and how to then show in Index View [closed]
I need to be able to calculate the number of business days difference between two dates: from DateRequestMade to DateIssued. I have used this code that I found:
var calculatedBusinessDays =
1 + ((...
1
vote
1
answer
81
views
Calculate quantity based on column from a different table
I currently am working with 2 tables tbRecords and tbInspectedParts. tbRecord has an auto increment column that is mapped back to the tbInspectionParts through column eRecordId.
Example - tbRecord:
...
2
votes
2
answers
251
views
Generated column with data type timestamptz (timestamp with time zone)
In PostgreSQL, I want to make a computed column, where end_datetime = start_datetime + minute_duration adding an interval to a timestamp.
I keep getting error, how can I fix?
ERROR: generation ...
2
votes
1
answer
80
views
How can I summarize sales data by category in a new column?
I would like to create a new column where I can sum units by quarter.
My table like this
Another column I would summ unit by product and quarter
Edit: Last two col with the expected result
Unit
...
-2
votes
1
answer
47
views
How can I insert data into virtual json columns in mysql? [duplicate]
How can I insert data into virtual json columns in mysql?
I am creating a table that has a jsonData field and a virtual id column.
CREATE TABLE table_json(
JsonData JSON NOT NULL,
id INT ...
1
vote
0
answers
54
views
How to show "PAST" (before today) + next 12 months with MMM X-axis labels
I'm trying to build a bar chart in Power BI where the X-axis shows the following:
A "PAST" bucket representing all data before today
The next 12 months, displayed as 3-letter month names ...
1
vote
1
answer
74
views
In maria db how do I create a table with a column generated by my sql function?
In Maria database 10.6.22 on ubuntu 24.04, I wrote a function to unaccent utf8 fields. It works fine when I apply it to column entries, but I want to use it to generate an unaccented column in a table ...
2
votes
1
answer
122
views
Why is timestamptz + interval considered mutable?
I tried to create a generated column that adds timestamptz and interval columns, but Postgres complains that this expression is immutable:
create table test ( ...
0
votes
0
answers
15
views
Sum Unique Hours in a table
My dataset has an Employee that has taken many trainings, but has also worked some {Hrs} on the same day. I want to get the sum of {hrs}, as a calculated field, that the employee has worked, where the ...
2
votes
5
answers
122
views
Mean of every n columns for each row in R
I have a monthly dataset of 36 IDs for 23 years. I am trying to calculate the annual means for each ID. Please see a subset of the data below.
structure(list(ID = c("AN", "AP", &...
0
votes
2
answers
78
views
Getting single MAX() row of Calculated Column within a Specific Time Interval in SQL
I am trying to get the MAX() of the sums of amps_a + amps_b + amps_c within the month of March for the ID column. This should return a single row for the highest sum for the month of March (or at ...
-2
votes
1
answer
54
views
combine two date columns - sort of Role Playing Dimensions
I have a scenario in Power BI:
I have a simple Transaction Table, with Order and Delivery years in two columns, with an Amount column.
I do not care about the ProductId column for my visuals; the ...
0
votes
1
answer
69
views
RANK() Always Returns 0 in SeaORM Query
I am using SeaORM in a Rust project and trying to retrieve ranked user balances using MySQL’s RANK() OVER (ORDER BY ...). However, the rank field always returns 0 for all rows.
Rust Code:
#[allow(...
1
vote
0
answers
36
views
Is there a way in Tableau to go through a series of numbers in a field (delimited by ",") then do a lookup for each from another data source?
I have a series of IDs in a Tableau column that I need to derive the actual names from another data source (like a vlookup or join via the ID), and display the actual names on a new Tableau field. See ...
0
votes
0
answers
51
views
MS Excel Pivot Table calculating variance column when data specific format
I have a data table and want to create a pivot table off it (top part of image) with a variance field Calculated as the NPV difference (change/movement) between Period D and F (middle part).
I have ...
0
votes
0
answers
8
views
Create 2 new columns in the dataframe, one called FishVolume and one called FishDensity
FishVolume is found by the formula: FishVolume = Lenght1 * Height * Width FishDensity is found by the formula: FishDensity = Weight / FishVolume Show the first 5 rows of the the dataframe with the new ...
0
votes
2
answers
485
views
How do I add a new column based on values of another column in Power Query?
I have a table that contains sales data over the course of several years on a fiscal calendar. Here is a snippet example of this data:
I would like to add another column (PY Sales) to see how we ...
0
votes
0
answers
64
views
Calculated Column with three conditions
I"m building a dashboard that will identify missing values for three data points: Billing, Reason, Origin. They are all text and do not contain numbers.
How do I construct a calculated column I ...
1
vote
1
answer
152
views
Pivot table (calculated field)
I'm working on a movie box office revenue spreadsheet. A pivot table was created for the movie data to make calculations of sum, average and count of revenue generated. Now I want to use a calculated ...
1
vote
7
answers
153
views
Return Value of Previous Row Column
I have the dataset below
Record_Number
Col1
Col2
Col3 (Calculated Column)
1
123
1
123
2
456
1
456
3
789
2
456
4
147
2
456
5
258
3
258
6
852
4
258
7
963
2
258
8
213
1
213
I can't figure out a way to ...
0
votes
1
answer
117
views
Computed Field fails because ANSI_WARNINGS = OFF
I am trying to have an auto-computed column to tell me the difference in hours between the 2 dates.
It will not let me do it because the database has ANSI_WARNINGS = OFF.
I know the best practice is ...
0
votes
0
answers
80
views
How to Exclude Specific Columns in Oracle APEX Interactive Grid Flashback?
I am working with Oracle APEX and using an Interactive Grid with Flashback functionality enabled. One of the columns in my grid is a query-only column (it is calculated using an SQL query and does not ...
0
votes
1
answer
111
views
How to calculate a running total of unique user_ids over the previous 30 days in Tibco Spotfire?
I have a dataset that contains number of logins by user_id per day. If I do a uniquecount([user_id]) in a cross table with [Date] in the vertical column, it gives me our Daily Active Users. I want ...
0
votes
1
answer
179
views
Using OFFSET to get the value from a previous row so that I can calculate the difference
I'm creating a report that will show that change in a particular column between one row and the one previous.
When I use the following DAX formula, nothing is shown in the column
...
1
vote
1
answer
79
views
New column in R data table via function that looks up in other data table
I have a data.table and want to add a new column:
big_table[, ("new_column") := some_function( col1, col2, … ) ]
The function may be defined as
some_function <- function( xCol1, xCol2, … ...
0
votes
1
answer
114
views
Microsoft Lists Sharepoint Calculated Column IF AND
I'm trying to create a calculated column IF statement in Microsoft Lists and wondered if anyone could help please?
Column: Date
Column: Leaver Reason Test
Column: Status
Calculated Column to be the '...
0
votes
1
answer
42
views
A table of multiple values was supplied where a single value was expected YTD
I am trying to calculate a table where I can see the YTD values with this DAX:
Is YTD =
IF (
'Append'[Attribute - Date] >= DATE ( YEAR ( DISTINCT ( 'Append'[Date Ref.EoMonth] ) ), 1, 1 )
...
1
vote
1
answer
81
views
Calculative consecutive values with DAX calculated column where values restart based on condition
I have a Power BI calculated table set up like the following with customer, item, week and cut cases. I'm looking to add another column that sums the number of consecutive weeks the cut cases > 0. ...
0
votes
1
answer
26
views
How to rank a totaledd column with Dax as a calculated Column
I have a dataset that has Grocery store name, department name, Employee name... I am trying to Count the number of employees by department to get a total number of employees by department and then ...
0
votes
1
answer
103
views
CAST AS DECIMAL returns text, why?
In a Libre Base query can anyone say why the following would fail to produce a numeric character with 4 decimals and instead return a column formatted as text showing two decimals? I want the query to ...
0
votes
2
answers
70
views
Create a MySQL statement joining multiple tables and doing a calculation after retrieving SUM, COUNT or NULL results [duplicate]
How do I create a SQL statement to paginate users calculated performance results?
Users
usersid | name etc...
1 | Satoshi
2 | Musk
Lessons with amounts
lessonsid | usersid | totalPay
1 | 1 | 200
2 | ...
0
votes
1
answer
90
views
R dbplyr percentages not calculated correctly from live connection to Microsoft SQL Server [duplicate]
I have a Microsoft SQL Server database which I have connected to with an ODBC link. There are three columns of interest in the table I am querying: serovar, reportyear and hospitalised.
Each row ...
2
votes
1
answer
77
views
Apply pandas dictionary with gt/lt conditions as keys
I have created the following pandas dataframe:
ds = {'col1':[1,2,2,3,4,5,5,6,7,8]}
df = pd.DataFrame(data=ds)
The dataframe looks like this:
print(df)
col1
0 1
1 2
2 2
3 3
4 ...
1
vote
1
answer
63
views
How do I take the output from R and store each piece of output into a separate column?
I am using the function "preventr" in RStudio. It basically is an equation that uses around 10 parameters to predict cardiovascular disease risk for patients. I have a dataframe with >50,...
1
vote
1
answer
67
views
Race condition for function creation in Postgresql 15 restore?
I ran into a situation with pg_restore that for all the world looks like a race condition to me. But this being Postgres I just can't believe I'm encountering an actual bug with something so straight ...
1
vote
1
answer
107
views
I use sqlalchemy and want to get new values of computed field in returning after updating
Simple sample:
from sqlalchemy import Column, Integer, Computed, update, insert, select
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
from sqlalchemy.orm ...
3
votes
1
answer
271
views
How to calculate the Exponential Moving Average (EMA) through record iterations in pandas dataframe
I have created a pandas dataframe as follows:
import pandas as pd
import numpy as np
ds = { 'trend' : [1,1,1,1,2,2,3,3,3,3,3,3,4,4,4,4,4], 'price' : [23,43,56,21,43,55,54,32,9,12,11,12,23,3,2,1,1]...
0
votes
1
answer
126
views
PBI Desktop Direct query - How to countrows
I'm in PBI Desktop; connected via direct query and trying to count the number of occurrence of a specified column; to use it then in column to be able to use it as slicer
Long story short; I've ...
1
vote
1
answer
55
views
Creating a GENERATED column using elements of a Composite type
I have a composite type:
CREATE TYPE objref AS (
objid nonnull_int8,
objtype nonnull_string
);
Have a table with an array column of the above composite type:
CREATE TABLE partner {
sw ...
1
vote
0
answers
51
views
Webi: Creating a calculated dimension?
I have a report with OrderIDs and related boolean dimensions for each order. I want to create a calculated dimension counting the boolean results for each dimension/object. Is this even possible in ...
0
votes
0
answers
280
views
Excel - Power Query - Calculated Column (Minimum Value)
I'm trying to create a column that only contains the minimum value of another column but keep running into an error. See below:
Power Query Window :
Any idea as to what is going on. It seems like ...
0
votes
1
answer
105
views
SQL QUERY with custom columns from SUM
I would like to build a SQL query to get the sum of hours(difference between end and start) by week for each person.
In my main table, I have 3 columns :
ID
startDT
endDT
1
01/01/2024 08:00
01/01/...
1
vote
1
answer
113
views
How to Filter and Query Based on a Computed Column in Laravel?
I'm working on a Laravel project where I need to calculate an estimated_value for each record in my SalesLead model by multiplying the probability and value columns. I want to filter records based on ...
1
vote
1
answer
79
views
How to create a new column using complex fomulas and variable outputs (i.e., recoding variables) in a Pandas DataFrame similarly to R's `case_when`?
Main Problem
Suppose I have the following Pandas DataFrame (code shared below):
Suppose further that I want to create a new column called NewVal according to the following rule (process often called &...
0
votes
3
answers
64
views
How to sum pandas columns across the same record for columns which begins with the same word
I have created the following pandas dataframe:
ds = {'col1' : [1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4],
'feature1' : [1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4],
'col2' :...
0
votes
2
answers
90
views
Columns in another table with the same width
Image to better explain the problem.
What I'm trying to do is make the columns in the second section the same as the first. So far, I've achieved this by adding 13% padding to the left and right sides ...
0
votes
1
answer
155
views
Postgres generated column cast Varchar to Date
I'am trying to use a generated column to cast a Varchar column to a Date column. The expression to generate the date consists of some string manipulation to derive an appropriate string that can then ...
1
vote
1
answer
23
views
Calculated column by combining 2 other columns where column A is ref column has duplicate distinct values
Calculated column by combining 2 other columns where column A is ref column has duplicate distinct values. If column B has result any row for that specific Ref in column then same should be the result ...