Looker Explore - display only latest day, unless date dimension is added - looker

In a Looker Explore, we want to display only the data from the latest date for each ID. For example:
ID
Probability
1
0%
2
50%
When we add in the date dimension, then we want to break it down by date:
Date
ID
Probability
Feb 5, 2023
1
0%
Feb 4, 2023
1
1%
Feb 3, 2023
1
2%
Jan 15, 2023
2
50%
Jan 14, 2023
2
45%
We want to define the probability as a measure for easier visualisation. Is this kind of behaviour possible in a Looker Explore?

Related

In R - How do I plot the data from the row where the date=='"2020 Q1' to the last row of the dataframe?

example of the data:
Date
Inflation
2020 Q1
2
2020 Q2
2.1
2020 Q3
2
2020 Q4
2.1
I am using ggplot ggplot(CPI,aes(x=date,y=inflation,group=1))+geom_line() but I would like to only plot from whichever row number that contains date= 2020 Q1 until the last row of the set (which will change everytime as I am getting webscraping the data from a website).

How to select specific column from imported table?

I am using the following formula in Google Sheets to pull in some financial data:
=TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT,"table",4))
The IMPORTHTML result is
Forward Annual Dividend Rate 4 2.04
Forward Annual Dividend Yield 4 1.11%
Trailing Annual Dividend Rate 3 1.94
Trailing Annual Dividend Yield 3 1.05%
5 Year Average Dividend Yield 4 2.02
Payout Ratio 4 32.93%
Dividend Date 3 Mar 11, 2020
Ex-Dividend Date 4 Feb 18, 2020
Last Split Factor 2 2:1
Last Split Date 3 Feb 17, 2003
I am TRANSPOSING the result to prepare the data for querying:
Forward Annual Dividend Rate 4 Forward Annual Dividend Yield 4 Trailing Annual Dividend Rate 3 ...
2.04 1.11% 1.94 ...
What I need is the value of the Ex-Dividend Date 4 column (so: Feb 18, 2020) (and later also other columns so I am seeking a generic solution). I have tried multiple ways (see below, but all resulting in #VALUE! errors:
=QUERY(TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT","table",4)), "SELECT * LIMIT 2 OFFSET 1 WHERE COL=""Ex-Dividend Date 4"")")
=QUERY(TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT","table",4)), "SELECT [Ex-Dividend Date 4] LIMIT 2 OFFSET 1")
How do I query this table correctly?
try:
=INDEX(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT",
"table", 4), 8, 2)
or already formatted:
=TEXT(INDEX(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT",
"table", 4), 8, 2), "mm/dd/yyyy")
in QUERY:
=QUERY(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT",
"table", 4), "select Col2 where Col1 contains 'Ex-Dividend Date 4'", 0)

Modeling a repeated measures logistic growth curve

I have cumulative population totals data for the end of each month for two years (2016, 2017). I would like to combine these two years and treat each months cumulative total as a repeated measure (one for each year) and fit a non linear growth model to these data. The goal is to determine whether our current 2018 cumulative monthly totals are on track to meet our higher 2018 year-end population goal by increasing the model's asymptote to our 2018 year-end goal. I would ideally like to integrate a confidence interval into the model that reflects the variability between the two years at each month.
My columns in my data.frame are as follows:
- Year is year
- Month is month
- Time is the month's number (1-12)
- Total is the month-end cumulative population total
- Norm is the proportion of year-end total for that month
- log is the Total log transformed
Year Month Total Time Norm log
1 2016 January 3919 1 0.2601567 8.273592
2 2016 February 5887 2 0.3907993 8.680502
3 2016 March 7663 3 0.5086962 8.944159
4 2016 April 8964 4 0.5950611 9.100972
5 2016 May 10014 5 0.6647637 9.211739
6 2016 June 10983 6 0.7290892 9.304104
7 2016 July 11775 7 0.7816649 9.373734
8 2016 August 12639 8 0.8390202 9.444543
9 2016 September 13327 9 0.8846920 9.497547
10 2016 October 13981 10 0.9281067 9.545455
11 2016 November 14533 11 0.9647504 9.584177
12 2016 December 15064 12 1.0000000 9.620063
13 2017 January 3203 1 0.2163458 8.071843
14 2017 February 5192 2 0.3506923 8.554874
15 2017 March 6866 3 0.4637622 8.834337
16 2017 April 8059 4 0.5443431 8.994545
17 2017 May 9186 5 0.6204661 9.125436
18 2017 June 10164 6 0.6865248 9.226607
19 2017 July 10970 7 0.7409659 9.302920
20 2017 August 11901 8 0.8038501 9.384378
21 2017 September 12578 9 0.8495778 9.439705
22 2017 October 13422 10 0.9065856 9.504650
23 2017 November 14178 11 0.9576494 9.559447
24 2017 December 14805 12 1.0000000 9.602720
Here is my data plotted as a scatter plot:
Should I treat the two years as separate models or can I combine all the data into one?
I've been able to calculate the intercept and the growth parameter for just 2016 using the following code:
coef(lm(logit(df_tot$Norm[1:12]) ~ df_tot$Time[1:12]))
and got a non-linear least squares regression for 2016 with this code:
fit <- nls(Total ~ phi1/(1+exp(-(phi2+phi3*Time))), start = list(phi1=15064, phi2 = -1.253, phi3 = 0.371), data = df_tot[c(1:12),], trace = TRUE)
Any help is more than appreciated! Time series non-linear modeling is not my strong suit and googling hasn't got me very far at this point.

Getting difference between two dates in days

I have a specific problem where I have records in my DB table like the following:
LastUpdated
10 January 2017
(The dates are stored in the database as a DateTime type.)
Now I need to fetch the difference in days between today's date and the last one including today's date. So, for example, today is the 12th, so the amount of days would be 2.
Now the second part of the problem is that I have another table setup like the following:
TransactionDate
1 January 2017
2 January 2017
3 January 2017
4 January 2017
5 January 2017
6 January 2017
7 January 2017
8 January 2017
9 January 2017
10 January 2017
So now after I perform a LINQ the updated results in my DBTable would look like the following:
3 January 2017
4 January 2017
5 January 2017
6 January 2017
7 January 2017
8 January 2017
9 January 2017
10 January 2017
11 January 2017
12 January 2017
So basically I'm trying to get the difference between the current date and the last updated date and then add it to the transaction details table. Upon adding the difference between two dates, I want to remove as much as the days in difference has been added, so that the total date span remains 10 days...
Can someone help me out with this?
Edit: this is the code so far:
var usr = ctx.SearchedUsers.FirstOrDefault(x => x.EbayUsername == username);
var TotalDays = (DateTime.Now - usr.LastUpdatedAt).Value.TotalDays;
Is this a correct way of fetching the difference between two dates like I've mentioned above?
Now after this I perform an HTTP request where I get the remaining two dates and insert it like:
ctx.TransactionDetails.Add(RemainingTwoDates);
ctx.SaveChanges();
Now I have dates expanding from 1st January to 12th of January, but I want to remove 1st and 2nd of January so that the total range of days stays 10;
How can I do this ?
You can remove transaction dates that are older than 10 days ago.
ctx.TransactionDetails.Add(RemainingTwoDays);
//Now you want to remove those older than 10 days
var today = DateTime.Today;
var tenDaysAgo = today.AddDays(-10);
var oldTrandactions = ctx.TransactionDetails.Where(t => t.TransactionDate <= tenDaysAgo).ToList();
foreach (var t in oldTrandactions) {
ctx.TransactionDetails.Remove(t);
}
ctx.SaveChanges();

Setting Up a Leave Plan Table in PeopleSoft 9.1

I'm challenged with a Leave Table setup issue and would like some guidance.
Background: I have a division at work where they do not accumulate any vacation time on their first year of service. All the accrued vacation time are backloaded and you receive the hours the following calendar year based on the previous year's service. I am having issues setting up the accrual service for the First Year Award Values because when I try to set the "Month Eligible" field to 13, it gives me an error. Screenshots can be provided or I can try to explain this better. But I'm up for any suggestions since I have a test environment to play around with this setup
Example 1:
DOH = jan 1, 2015 on Jan 1, 2016; member would accrue 10 days based on the service from Jan 1, 2015 to Dec 31, 2015 on Jan 1, 2017; member would accrue 10 days based on the service from Jan 1, 2016 to Dec 31, 2016
The breakdown for the 1st year of service is prorated based on month of hire:
Example 2:
DOH = feb 1, 2015 on Jan 1, 2016; member would accrue 9 days based on the service from Feb 1, 2015 to Dec 31, 2015 on Jan 1, 2017; member would accrue 10 days based on the service from Jan 1, 2016 to Dec 31, 2016
Example 3:
DOH = mar 1, 2015 on Jan 1, 2016; member would accrue 8 days based on the service from Feb 1, 2015 to Dec 31, 2015 on Jan 1, 2017; member would accrue 10 days based on the service from Jan 1, 2016 to Dec 31, 2016
with continuing the breakdown until the 12th month.
Example 4:
DOH = dec 1, 2015 on Jan 1, 2016; member would accrue 0 days based on the service from Dec 1, 2015 to Dec 31, 2015 on Jan 1, 2017; member would accrue 10 days based on the service from Jan 1, 2016 to Dec 31, 2016
Will this be part of the "Special Calculation Routine" checkbox?
I suggest using the Service Calc at Year Begin box instead. That will calculate leave accruals based on service as of Jan. 1 of the current year. For the accrual setup, try the following:
Service Units = Months
Accrual Rate Units = Hours per Year (Award Frequency = First Run of Year)
First Year Award Values ==> NOT USED
Accrual Rate Values (You did not indicate subsequent years, so you may need more intervals.)
After Service Interval Accrue Hours At
13 Service Months 10 Hours per Year
Service Bonus Values (Assuming no accrual if hired after October)
After Service Interval Award Bonus Hours
3 Service Months 1.000000
4 Service Months 1.000000
5 Service Months 1.000000
6 Service Months 1.000000
7 Service Months 1.000000
8 Service Months 1.000000
9 Service Months 1.000000
10 Service Months 1.000000
11 Service Months 1.000000
12 Service Months 1.000000
The SBV's + Svc Calc # Yr Begin should cover your first year requirement, but you may need to tweak the setup if I did not understand it correctly.

Resources