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
3
votes
1 answer

Power BI measure based on last column value and filter

I have a table with records of some people's weights: Year Person Weight 2010 Mike 75 2010 Laura 60 2011 Mike 80 2011 Laura 55 2012 Laura 58 I want to create a Measure to find out the average weight based on the last…
Panda Coder
  • 157
  • 1
  • 9
3
votes
3 answers

How to perform an operation on specific columns within pandas dataframe while preserving other columns

I am trying to perform an operation on all columns within my pandas dataframe except one. I first tried: df=df[:,1:]*0.001 returned an error message. Then tried: df=df.iloc[:,1:]*0.001 I want the operation to be performed on all columns except…
spc963
  • 31
  • 1
  • 3
3
votes
2 answers

Pandas DataFrame - assign 1,0 values based on other column

I've got a dataframe containing country names & their percentage of energy output. I need to add a new column that assigns a 1 or 0, based on whether the country's energy output is above or below the median of energy output. Some dummy code…
Silent-J
  • 322
  • 1
  • 4
  • 15
3
votes
1 answer

Create table with calculated column

I want to create table with three columns: START_DATE|END_DATE|TOTAL_TIME START_DATE and END_DATE should both be dates. TOTAL_TIME should be calculated by using these two columns. How can I create the table?
Kate
  • 445
  • 3
  • 9
  • 22
3
votes
2 answers

Calculated MYSQL Column

I currently have a table that has 4 columns - valueone, valuetwo, valuethree and additioncolumn. I would like to know how to make the additioncolumn store the addition of valueone+valuetwo+valuethree. I am new to MySQL and tried some syntax I found…
Nddy
  • 31
  • 1
  • 3
3
votes
4 answers

How can I get only numbers from a string as a computed column in SQL Server with no leading zeroes?

Background Currently I have a function to get only numbers (with no leading zeroes) from a string (let's call the two variables @alphaNumeric and @strippedNumber). It turns out that it is more efficient to have @strippedNumber pre-calculated on the…
Ilessa
  • 602
  • 8
  • 27
3
votes
1 answer

Counting Folder Depth with PowerShell

1. Code Description alias how it is intended to work User enters a path to a directory in PowerShell. Code checks if any folder within the declared directory contains no data at all. If so, the path of any empty folder will be shown on the prompt to…
間澤東雲
  • 149
  • 3
  • 9
3
votes
4 answers

How can I add four calculated values to a result set from a Stored Proc (TSQL)?

I need to extend an existing Stored Procedure (that is, create a new SP based on the legacy one) to include some additional, calculated data. Four additional columns are needed to feed the report that is generated from the results of the SP: In a…
3
votes
2 answers

Create column in R in a large database

My apologies if this question has already been answered, but I haven't found it. I'll post all my ideas to solve it. The problem is that the database is large and my PC cannot perform this calculation (core i7 and 8 GB RAM). I'm using Microsoft R…
3
votes
2 answers

Pandas Calculate Sum of Multiple Columns Given Multiple Conditions

I have a wide table in a format as follows (for up to 10 people): person1_status | person2_status | person3_status | person1_type | person_2 type | person3_type 0 | 1 | 0 | 7 | 4 | …
shishy
  • 787
  • 1
  • 15
  • 31
3
votes
1 answer

Using SQL Server spatial types in SSIS data load

I am trying to load a file using the SQL Server Import Data function - appending rows to an existing table. my existing table is created like this: CREATE TABLE [dbo].[load]( [Long] [varchar](50) NULL, [Lat] [varchar](50) NULL, [Geog] …
Adam Stewart
  • 1,983
  • 1
  • 18
  • 25
3
votes
1 answer

Calculating percentages of total at equal intervals in a data set in R

I am working on a dataset that contains the total for each FMCG category and its distribution of sales by each major channel as indicated in the columns. The extract is as below CTY totsal MTsal GTsal Othsal totsal MTsal GTsal Othsal …
user36176
  • 339
  • 1
  • 2
  • 11
3
votes
1 answer

Can I create an index on a computed column?

My table has this structure. CREATE TABLE [dbo].[Word] ( [WordId] VARCHAR (20) NOT NULL, [CategoryId] INT DEFAULT ((1)) NOT NULL, PRIMARY KEY CLUSTERED ([WordId] ASC), ); What I would like to do is to add a column…
Samantha J T Star
  • 30,952
  • 84
  • 245
  • 427
3
votes
2 answers

Insert a column from another table using calculated column as a key in Spotfire

I have two tables (A and B) that are related through the following four columns: TECHNOLOGY - LAYER - YEAR - WORKWEEK YEAR and WORKWEEK are calculated columns in both of the tables. I have a column (WAFCOUNT) in table A that I want to insert into…
3
votes
2 answers

Computed Column - as Primary key

I have the following Computed Column within the create table function: Create table test ( Code1 nchar(10), Code2 nchar (10), Type nchar(10), Final AS CASE WHEN LEN(Code1)>0 THEN Code1 WHEN LEN(Code2)>0 THEN Code2 ELSE Type END ); Alter table…