Adding a date for the Maximum of three dates in XSLT - xslt

Could you please help me on fetching the date +1 for the maximum of three dates?
Description:
I have built a code in XSLT to fetch maximum of three dates.I want to add one date for the maximum date what i get .
Can anyone please help me on this?
Thanks & Regards,
Gowthami H J

Assuming you use XSLT 2 or 3 (which the use of xs:string suggests) you can simply apply the date arithmetic https://www.w3.org/TR/xpath-functions/#dateTime-arithmetic provided in XPath 2 and later for the xs:date/xs:dateTime and the duration data types e.g. in
max(item/xs:date(.)) + xs:dayTimeDuration('P1D')
max(item/xs:date(.)) computes the maximum date of the sequence of item elements and the + operator adds a duration of one day.
http://xsltfiddle.liberty-development.net/pPqsHTX

Related

How to replace missing values in panel data?

I am looking into weekly earnings data, where I have defined my data as pre-pandemic earning data and post-pandemic earning data. Now for some individuals, I have some missing values for the post-pandemic period which I want to replace with their pre-pandemic earnings. However, I am struggling with the coding for this panel data. I was hoping someone could help me with. Thanks in advance.
It is always easier if you share example data (see dataex) or at least list what variables you have. The example below will therefore most likely need to be edited.
* Sort the data by individual id and the time unit
* that indicates if this the obs is pre or post pandemic
sort id time
* This replaces the earnings value with a missing value if the
* id var is the same as on the next row AND the earnings var
* on is missing on the next row
replace earnings = . if id == id[_n+1] & missing(earnings[_n+1])
This assumes that all individuals are indeed represented in each time period and that you have a unique id variable (id) in your data set.

How to filter dates based on its time in Loopback 4?

I want to find out all the dates which have time more than 10.30 am.
let whereBuilder = new WhereBuilder();
whereBuilder.gt('sessionStartedOn', '10:30:00');
Obviously, this doesn't work. Are there any wildcard characters I should be adding?
The query in PostgreSQL would be something like this -
SELECT * FROM table WHERE date_part('hour', sessionStartedOn) >= 10 AND date_part('minutes', sessionStartedOn) > 30;
I think the second parameter should be of the same type as the value contained by the variable named by the first parameter. In your case I presume it is date. For example: "2022-01-18T00:00:00.000Z"
https://loopback.io/doc/en/lb4/apidocs.filter.wherebuilder.lte.html
PS. If you want to filter for values greater than the value passed as a parameter you should use .gt (>) or .gte (>=) methods.

Can we create Dynamic Date table in mapping Data Flow?

I have a query in Power BI that takes two parameter: Start Date and End Date.
Whenever I pass these Dates it return a table of Date that contain few columns created according to this range of date such as Date, QuarterofYear, Year, MonthName......etc.
Can we create a mapping data flow in ADF that takes two parameter as input and return a calculated table according to provided dates?
Is there any function that return the range of dates?
For your request: "I want that I pass two date Start Date and End Date in ADF Mapping Data Flow , and Data flow will Create a column such as "Date" that contain that number of Date rows. Is there any function for this? Exam. Start Date=20-01-2019, End Date=20-01-2020 Then Date Column Values should be: 20-01-2019 21-01-2019 ......... ......... 20-02-2020", according the Data Factory documents and my experience, the answer is no, we can't achieve it in Data Flow.
There is a solution to this, but it is a bit tricky.
TL;DR
The general data flow looks like this:
We need a dummy source with exactly one row which contains whatever.
Then we derive a column where we use the mapLoop() expression to create an array of all the dates we want to get rows for.
Finally, we need to flatten the array column which will result in one row per array entry and thus one row per date.
Walkthrough
Source dummy
Each dataflow needs a source and we need exactly one row to make our dataflow work. To achieve this I've created a dataset called empty of type CSV in my data lake which has this content:
empty
""
This is our source definition:
And its result looks like this:
Derived column days
This is where the magic happens!
We create a new column dates which is an array of all the dates we want to have in our date table:
In this scenario we want a date table starting on 2019-01-01 and reaching one year into the future. The full expression looks like this:
mapLoop(
addDays(currentDate(), 365) - toDate(2019-01-01),
addDays(toDate(2019-01-01), #index)
)
This is what happens here:
the mapLoop() function builds an array of elements. You specify the number of elements you want to have and the lambda expression to calculate each of the elements. For example, mapIndex([1, 2, 3, 4], #item + 2 + #index) results in [4, 6, 8, 10]
addDays(currentDate(), 365) - toDate('2019-01-01') is the number of days between our start (2019-01-01) and end date (1 year in the future from now) and thus the number of dates we want to have in our resulting array.
addDays(toDate(2019-01-01), #index) calculates each array item by adding #index days to our start date. This is executed for the number of days we've calculated before and #index is the array position. Thus, the first element of the array will be 2019-01-01 + 1, the second 2019-01-01 + 2 and so on.
Our stream now has these columns:
Flatten
Finally, you need a flatten transformation which will expand each item in your array to its dedicated row. We can also dismiss the useless empty column in this step:
And this finally results in what we wanted to achieve:
References
Data transformation expressions in mapping data flow

Powerbi - DAX: COUNT & GROUP BY - Count all coversation id's per Queue

I've been struggling with the next one. I need to make the sum of every unqique conversation ID per Queue.
There are 2 Tables I would like to us: Query and Segment.
First attempt to use "Group By"
Total Answered Calls =
GROUPBY(segment;queue[name];"Total Answered"; COUNTX(CURRENTGROUP();COUNT(segment[conversationid])
))
I keep on recieving the error "The expression refers to multiple Columns [...] cannot be converted to scalar value.
Dit I use "Group B"y wrong or do I need another approach?
Many Thanks!
Well this did the trick.
Total Answered Calls = (SUMX(SUMMARIZE(segment; segment[queueid];"Total Answered"; [Calls Answered]);[Total Answered]))
Thanks anyway!

Sum values in one column of all rows which match one or more of multiple criteria

I have some table data in which I'd like to sum all the values in a specific column of all rows where column A contains string A and/or column B contains string B. How can I achieve this?
This works for one criterium:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")))
I tried this, but it didn't work:
=SUM(FILTER(G:G,OR(ISTEXT(REGEXMATCH(F:F,"stringA")),ISTEXT(REGEXMATCH(C:C,"stringB")))))
Please try:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")+REGEXMATCH(C:C,"stringB")))
+ works for or logic. ISTEXT is not needed because REGEXMATCH gives true or false.
OR does not work because filter is an arrayformula, use + in array formulas.
=SUM(FILTER(G:G,REGEXMATCH(F:F&C:C,"stringA|stringB")))
OR is denoted by |
EDIT Added &C:C to denote different Columns