I am trying to do some analysis on SPY stock data and trying to see how the price changes based on % change on a single day. For example if the percent change is greater than 2
((Open-close) / open) * 100 > 2
Find the next row and the percent change (Of that row only, like open - close) (Price change for next day). Day after next percent change. and 3rd day change. AND the sum of the change for 3 days. I have no background in Spark but know the data concepts. What would be the easiest way to go about solving this query?
Date Open High Low Close
"2022-06-17" 365.48 369.37 362.17 365.85
"2022-06-16" 370.54 370.94 364.08 366.93
"2022-06-15" 377.43 383.87 372.12 379.13
"2022-06-14" 376.85 377.93 370.59 373.82
"2022-06-13" 379.85 381.81 373.31 375.01
"2022-06-10" 394.88 395.76 389.75 389.81
"2022-06-09" 409.34 411.71 401.45 401.47
"2022-06-08" 413.9 415.82 410.38 411.29
"2022-06-07" 408.07 416.22 407.61 415.7
Related
If I have an average YOY growth of say 2.5%, current year sales of $500,000, and target sales of $1,000,000. Is there a way to calculate the number of years until I hit my target (assuming a continued YOY growth rate of 2.5%), without calculating each additional years's sales on a different row?
You can use the NPER function for this:
=NPER(Growth,0,currentSales,-targetSales)
Note that this gives the same result as #Dominique, but is using a built-in Excel function.
Also, by virtue of the nature of Excel financial functions, the signs for the current and future Sales need to be different.
There's a simple formula for this:
Money_end = (1+r/100)^Y*Money_begin
Where:
Money_begin = the starting amount of money, in this case 500000.
Money_end = the finishing amount of money, in this case 1000000.
r = the percent ratio, in this case 2.5.
Y = the amount of years, which you are looking for.
So, your question comes down to solving this equation:
1000000 = (1+2.5/100)^Y * 500000
2 = 1.025^Y
Y = log(2)/log(1.025)
If you want this to be solved by Excel, you might use the formula and use the Solver basic Excel feature for coming up with the same (but numerical instead of analytical) result.
I have a dataset which is amount (parts per million) against time (every minute)
I need to find the peak for each day, so that I can plot that against other data, I can manually do this using =MAX( but I have a lot of data points and I am sure there is a better way
Many Thanks for the help
I don't know where and how you want show this data, but, if you want get a max value amount per day, you can try add an array formula, like that:
=MAX(IF($COL_DATES = $DAY, $COL_VALUE, 0))
Replace $COL_DATES to your column of day date, replace $DAY to value of day what you want get max value and replace $COL_VALUE to your column of values.
After press CTRL + SHIFT + Enter
I have two dataframes, which I join to see the active people. There are people who stop being active and I use one of the dataframes to fill the other one.
mass pnr freq
1 [40666303, 68229102, 35784905, 47603805] 4
54 [17182402] 1
234 [07694901, 35070201, 36765601] 3
The other table looks the same I just need to select enough people to reach my target of 7500-7600 people (40666303 - this is one person and 'freq' is the number of people in the list. It doesn't matter what is the 'mass', I just need when the sum of 'freq' is between 7500 and 7600 the process to stop. Now I need 400 people, but next month it is possible to need 20 people, it differs every month. Basically, my code now removes the non-active people and when it removes them i need to replace them with active. The first run of the process I used this code to select the initial 7500 people:
target = 7500
freq_sum = sum(mass_grouped3['freq'])
new_mass_not_in_whitelist1['records_to_select'] = [math.ceil(int((el * target ) / freq_sum )) for el in new_mass_not_in_whitelist1['freq']]
But now, with this code I am not getting the desired sum of people to fill the missing gap of 400 people. Also, it would be good to not select only the first rows, but maybe every other or some random condition. What can I change to work the way I explained?
I managed to get in Excel desired % of time difference from column E, easy job just changed the Data Type to Percentage. What are we calculating is % of these TimeDifferences, one per one (other columns inconsiderable).
The same thing isn't in PowerBI, where I am not able to calculate it properly, always getting "1" before comma and then the result - you can compare it in both tables/columns what I am talking about.
I am looking for the way/DAX/measure how to properly calculate it, no matter in decimals or directly to percentage, as long as the % is the same as in Excel column. Any ideas?
P.S Left is Excel and right is PowerBI!
Seems Excel is basing the percentage on 24 hours, this I used in the calculation (24 hours = 24 * 3600 seconds).
I started combining in power query the date and the time, this has to do with the fact that you go over the day and your calculation still needs to be correct.
Go to query editor. select both columns, combine them. Next change the type to Date/Time, result:
Save and close editor.
In Power Bi, add a column:
NextDate = LOOKUPVALUE(Explog[Date];Explog[Index];Explog[Index] + 1)
This is picking up the next Date based on Index + 1
Add another column TimeDiffSec, calculating the datediff in seconds:
TimeDiffSec = DATEDIFF(Explog[Date];Explog[NextDate];SECOND)
Last step is adding a column for percentage:
% of time difference =
var perc = Explog[TimeDiffSec]/ (24*3600)
return if(perc >= 1; perc - 1; perc)
End result:
Note: If you have a situation you do not want to mix the System (STYRAX - scrubber) you can use the following for the NextDate:
NextDate =
var nextIndex =
CALCULATE(MIN(Explog[Index]);
FILTER(Explog;Explog[Index] > EARLIER(Explog[Index]) && Explog[System] = EARLIER(Explog[System])))
return
LOOKUPVALUE(Explog[Date];Explog[Index];nextIndex; Explog[System];Explog[System])
There is view listing a certain number of documents having as view selection a form. A column ( Style = Date/Time displaying Time ) has the formula: time_1. The next column is displaying: time_2.
with other words:
time_1 - the time the user was at work.
time_2 - the time the user must be at work ( let's say 08:00 hours ).
There is a view action button:
t1:=#DbColumn("Notes":"NoCache";"server/Company":"Name.nsf";"vwSearchResult";6);
total1:= #Sum(#ToNumber(t1)) ;
t2:=#DbColumn("Notes":"NoCache";"server/Company":"Name.nsf";"vwSearchResult";7);
total2:= #Sum(#ToNumber(t2)) ;
zile:=(total1-total2)/8; // 8 - is the minimun number of hours / day. " I must be at work minimum 8 hours "
#Prompt([Ok];"Time at work";#Text(total1));
#Prompt([Ok];"expected time";#Text(total2));
#Prompt([Ok];"Additional time - in days ";#Text(zile))
Just the 2nd Prompt is calculated correctly. The 1st prompt result is an integer number, and of course, implicitly the 3rd prompt is not displaying the result correctly.
How can I achieve this?
Change your formula to
t1:=#DbColumn("Notes":"NoCache";"server/Company":"Name.nsf";"vwSearchResult";6);
total1:= #Sum(t1 - [00:00]) / 3600;
t2:=#DbColumn("Notes":"NoCache";"server/Company":"Name.nsf";"vwSearchResult";7);
total2:= #Sum(t2 - [00:00]) / 3600;
You can't convert a time value to a number with #ToNumber. Instead, calculate the difference between your time and 00:00. This gives you the number of seconds of your time.
Divide this by 3600 and you get the hours.
I think its better to insert a column to the view which calculates the difference between time_1 and time_2.
Your #DbColum will now run on the new column ans calculates the difference.