Questions tagged [calculated-columns]

A calculated column is calculated from an expression that can use other columns in the same table

A calculated column is calculated from an expression that can use other columns in the same table. The expression can be a noncomputed column name, constant, function, and any combination of these connected by one or more operators. The expression cannot be a subquery.

2235 questions
4
votes
1 answer

Grouping objects on the property in PowerShell

I would like the Application and ShortcutName columns to be grouped into one column, while keeping the Version and Architecture columns as they are : $object | Select-Object -Property Application, Version, Architecture, ShortcutName | …
A. Joson
  • 89
  • 1
  • 7
4
votes
1 answer

SQL Server: Bulk Insert into table with computed column

I try to insert data from a textfile into a SQL Server 2016 table with a computed column with bcp. My bcp command: bcp Test.dbo.myFirstImport IN D:\myFirstImport.txt -f D:\myFirstImport.xml –T My table: CREATE TABLE [dbo].[MyFirstImport]( …
afj
  • 179
  • 1
  • 5
  • 13
4
votes
2 answers

Power BI: Simple addition give wrong result

I'm counting number of unique IDs per month in given timeframe and I've ancountered two strange things: 1. Looking for the same thing but using two different approaches (value for each month and cumulative value month by month) gives different…
Uzzy
  • 431
  • 1
  • 8
  • 16
4
votes
1 answer

How to calculate multiple columns from multiple columns in pandas

I am trying to calculate multiple colums from multiple columns in a pandas dataframe using a function. The function takes three arguments -a-, -b-, and -c- and and returns three calculated values -sum-, -prod- and -quot-. In my pandas data frame I…
4
votes
2 answers

Create new pandas column based on categorical values in other column (python)

I have a data frame with country and traffic columns: Country | Traffic US 8687 Italy 902834 Germany 2343 Brazil 4254 France 23453 I want to add a third column called "Region" to this data…
jeangelj
  • 4,338
  • 16
  • 54
  • 98
4
votes
1 answer

Is there a way to pivot rows to columns in MySQL without using CASE?

There are lots of posts out there on pivoting rows into columns for various databases. They seem to fall into two camps, using case statements or using a built in function of the database vendor. I am using MySQL and have not found anything so far…
Scott
  • 16,711
  • 14
  • 75
  • 120
4
votes
1 answer

How to read formulas of Calculated Columns in an Excel Table/ListObject without any data rows

I have a ListObject with an external query as the data source, which returns 18 columns. The ListObject has previously had an additional 4 calculated columns added. Right now, the ListObject has 0 data rows, however, while there are 0 data rows, I…
ThunderFrame
  • 9,352
  • 2
  • 29
  • 60
4
votes
1 answer

How can I create a DataField that calculates values in EPPlus?

I am porting Excel Interop PivotTable code to EPPlus. I'm at a sticking point in generating a calculated field value. In Excel Interop I can do it this way: pvt.AddDataField(pvt.PivotFields("TotalQty"), "Total Packages",…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
4
votes
2 answers

How to calculate the values of a pandas DataFrame column depending on the results of a rolling function from another column

A very simple example just for understanding. The goal is to calculate the values of a pandas DataFrame column depending on the results of a rolling function from another column. I have the following DataFrame: import numpy as np import pandas as…
Gilberto
  • 813
  • 7
  • 17
4
votes
1 answer

Will Microsoft SQL Server efficiently handle a non-persisted computed column?

I'm having a hard time phrasing this question in such a way that doesn't turn up results for persisted, indexed computed columns. My question is, if I have a table such as: CREATE TABLE Customers ( ID int, Name nvarchar(50), Balance…
Josh
  • 68,005
  • 14
  • 144
  • 156
4
votes
2 answers

Calculating correlation coefficient using PostgreSQL?

I have worked out how to calculate the correlation coefficient between two fields if both are in the same table: SELECT corr(column1, column2) FROM table WHERE ; ...but I can't work out how to do it when the columns are from different…
Dave
  • 125
  • 1
  • 2
  • 5
4
votes
1 answer

Create a computed column and round

I have 3 numeric(18,2) columns in my table. I want to create a fourth column that is computed. I created the computed column in SSMS as numeric (18,2) just like the other 3 columns. When I run a SELECT against my new column, it computes it fine,…
ScottG
  • 10,711
  • 25
  • 82
  • 111
4
votes
2 answers

Responsive columns with percentage max-width

What I need is very simple, or atleast it should be, but after days of research I've come to resort to asking on stackoverflow if anyone actually has any idea how to do this... I have 3 columns of content, all of which have expandable content…
KittenCodings
  • 575
  • 1
  • 5
  • 20
4
votes
3 answers

dplyr: how can I write equivalent to table() base function and preserve column names?

dplyr is fast and I would like to use the %.% piping a lot. I want to use a table function (count by frequency) and preserve column name and have output be data.frame. How can I achieve the same as the code below using only dplyr functions (imagine…
userJT
  • 11,486
  • 20
  • 77
  • 88
4
votes
2 answers

How to use a calculated column in where condition?

How to use a calculated column in the where condition in Oracle 9i? I want to use something like select decode (:pValue,1, select sysdate from dual, select activation_date from account where AcNo = 1234) as…
Sachin
  • 20,805
  • 32
  • 86
  • 99