Date Time is not being pulled from the database where numbers from the same column are being pulled in my report - sql

I have two columns:
The first column can only have values 1 or 2.
if 1, then my second column has a number.
if 2, then my second column has a Date Time -( something like this 1/1/2014 12:00:00 AM ).
What I am doing:
I have a tablix with 2 columns..
First column is named a and second is named b
under first I want numbers and under second I want the date time. Basically want to split the second column based on what's on first column i.e. 1 or 2
I have used expressions:
=IIF(Fields!first_column.Value=1, Fields!second_column.Value,nothing)
and for second
=IIF(Fields!first_column.Value=2, Fields!Second_column.Value,nothing)
it works prefectly for the number and gives result whereas the column where there should be the date time gives blank with no results. I have tried switching them, using numbers on both and using dates on both column. but every attempt the numbers work the date time doesnt work.
If I was too wordy and didnt make sense, please let me know and I can answer your specific qustions.
Thank you.

Related

Not sure how to create a SQL formula that subtracts timestamps in the same column to get the seconds between actions

Need assistance with creating a "datediff" type of formula.
I have timestamps in the {incilog} table, in different rows across the same column {incilog.timestamp} that I need to subtract from one another, but only if the {incilog.transtype} equals "TR" from the row that has the {incilog.transtype} equal "FPS".
Logic is: If {incilog.transtype} equals "TR" and {incilog.transtype} equals "FPS", then subtract {incilog.timestamp} from {inciog.timestamp} in the corresponding row.
Basically, I need to get how many seconds it took from "TR" to "FPS".
THANK YOU FOR YOUR TIME AND ASSISTANCE!
EXAMPLE OF DATA
timestamp
inci_id
transtype
descript
8/22/2022 12:14:46 AM
2022264051
TR
Time Received
8/22/2022 12:17:00 AM
2022264051
FPS
Fire Pri. Started

How to create a calculated column with unique values ​for every field

I'm currently facing a problem working with a CV on SAP HANA.
Basically my goal is to create a calculated field on every row, based on the content of another field of the same row.
More specifically, I have a column of dates with the current format (YYYYMMDD) and I have to automatically create an associated field based on current criterias:
the date with the current month and year has to be associated with 0;
every month after the current one, has to be, in order, increased by one (example: for 20220930 I have 0, for 20221030 I have 1, for 20221230 I have 3.. for 20231230 I have 15, this until 600);
if more than one row has the same date, the calculated field has to be the same, that means that, for example, if more than one row has 20221030, I need to have 1 on all of them).
My first idea was to use a rank node, but the outcome is not as I expected.
Attached, there is a screenshot of a data preview of my attempt (just showing the dates and rank_field columns..).
Any advice is welcome, thanks.
Example of data

Pandas- Difference of two column using column position

I have a Dataframe where I would like to find the difference between two columns, however would like to use the column position instead of the column name when I am trying to find the difference.
Sample Dataframe:
id, purchase_date, cost, service_date
101, 01-01-2022, 101, 04-01-2022
102, 01-05-2022, 101, 03-21-2022
I would like to find the difference between purchase_date and service_date, however trying to use the column position instead of column name
I tried something like this but it failed:
df.iloc[:,1] - df.iloc[:,3]
Expect to add one more new column that would give difference in days between these two columns.
Well first of all, what's you date format?
this solution assumes the following format %m-%d-%Y
df['difference'] = pd.to_datetime(df['purchase_date']) - pd.to_datetime(df['service_date'])
you can also add what ever format you have like
pd.to_datetime(date, format='%Y/%m/%d %H:%M:%S')

Conditional mean calculation in excel

I have a dataset organized as following :
The column A is the name
The column B is the date
The column C is the value registered for that person in that day
How can i calculate for the whole dataset a mean of the value of that person in the 30 past days without manually ordering for name and making the mean checking the date?
Try the AVERAGEIFS function with the EDATE function giving you a one month window.
=AVERAGEIFS(C:C, A:A, "Jack", B:B, ">"&EDATE(TODAY(), -1), B:B, "<="&TODAY())
    
You can use a nested array formula (Ctrl+Shift+Enter instead of Enter):
=AVERAGE(IF($A$2:$A$15=A2,IF($B$2:$B$15>=TODAY()-30,$C$2:$C$15,""),""))
Add columns for these two fomulas:
=COUNTIF(A1:A4,"Jack")
=SUMIF(A1:A4,"Jack",C10:C13)
That will give you the count, and it will give you the sum. With those two you can calculate the mean.
That's the basic idea, anyway.
Of course, you can add another count for the date ranges. It's all the same sort of thing.

Excel logic - matching columns

My situation is the following:
The 'Day' column is 1 to 365, and each day is repeated 24 times (for the 24 hours). Each day and hour together have a Degree value, represented by the B column. I need to multiple the B column with the E column everytime A column matches D (eg. B2*E2, B3*E2, B4*E2, B7*E3).
How can I do that? I'm really confused here.
Thank you
Using your shown example, in cell C2 and copied down:
=B2*VLOOKUP(A2,$D$2:$E$366,2,FALSE)
Two ways:
VLOOKUP(A2,$D$2:$E$366,2,FALSE)*B2
SUMPRODUCT(B2*($D$2:$D$366=A2)*$E$2:$E366)