how to get the next day date in informaitca - informatica

I have a date field coming form source paid_date and i want it to convert as
trunc(next_day(sysdate-1,'MON')).. I need to get the NEXT_DAY here and the filed data type is date-time.
Please share your inputs.

Unfortunately, as of now, there is no NEXT_DAY equivalent in Informatica. So you have to calculate it like this in expression.
TRUNC(
ADD_TO_DATE(
SYSDATE,
'DD',
(9 - TO_FLOAT(TO_CHAR(SYSDATE,'D')))%7
)
)
Explanation:
(9 - TO_FLOAT(TO_CHAR(SYSDATE,'D')))%7 - Calculates the number of days till next Monday.
ADD_TO_DATE(SYSDATE,'DD',...) - Adds the above no. of days to the input date

In this case you can use Add_To_Date function. Using this function you can get your exact date or month or year.
Formats of defining date,
Date – DD, DDD, DY and DAY
Month – MM, MON and MONTH
Year – YY, YYY and YYYY
Hour – HH, HH12 and HH24
Minute – MI
Seconds - SS
Syntax : ADD_TO_DATE (date_column, format, value)
Example: ADD_TO_DATE (Date, ‘DD’, 10)
Result:
10/01/2016 - 20/01/2016
As the format is provided as ‘DD’ and value as 10, the dates are displayed by increasing 10 days. This logics stands for date, month, year, minute, hour or seconds whatever defined in the syntax. To decrease the date value just add negative number (-10).
For you to get next day, just define
ADD_TO_DATE (Your column, ‘DD’, 1).
For more details on informatica just visit my blog,
http://etlinfromatica.wordpress.com/

Related

Week Ending Date from Week no. - GCP

How do I get the week ending date from week no. in GCP ?
SELECT 
Session,
Store_Num,
Store_Name,
EXTRACT (WEEK(Monday) from Route_Date) as Weekno,
AVG(Planned_DPH) as Avg
FROM `TABLE` 
WHERE Route_Date  between current_date() - 60 and current_date()
and Store_Num = 8881
GROUP BY 1,2,3,4
ORDER BY Weekno
You can get the first day of weekno with PARSE_DATE function and %W format string.
%W - The week number of the year (Monday as the first day of the week) as a decimal number (00-53).
And by adding 6 more days to the first day of the week, you will get the week ending date.
Consider below sample query.
WITH sample_data AS (
SELECT DATE '2022-11-10' AS Route_Date
)
SELECT *,
PARSE_DATE('%Y%W', Year || Weekno) AS startday_of_weekno,
PARSE_DATE('%Y%W', Year || Weekno) + 6 AS lastday_of_weekno
FROM (
SELECT EXTRACT(WEEK(Monday) from Route_Date) as Weekno, -- 45
EXTRACT(YEAR FROM Route_Date) AS Year,
FROM sample_data
);
Query results

How to get week number per month on Power Bi?

I have a a column called Date originated that hold the a date like "Tuesday, March 21, 2022".
I want to get that week number per month but the following gives me incorrect numbers.
The following DAX: Week of Month = 1 + WEEKNUM('ECR'[Date Originated]) - WEEKNUM(STARTOFMONTH('ECR'[Date Originated]))
gives me 1 for that date.
Some entries are correct like for Wednesday, April 6, 2022 I do get 1
The problem is not the DAX expression, but the date column, which you didn't share with us.
STARTOFMONTH is not the right choice of function here, since that function does not by default return the first date of a given month; rather, it returns the first date of the month for the supplied dates (within the current context).
Here you are supplying only one date, and so, for example:
=STARTOFMONTH(21/03/2022)
will simply return 21/03/2022.
You should be using
=
1 + WEEKNUM( 'ECR'[Date Originated] )
- WEEKNUM( EOMONTH( 'ECR'[Date Originated], -1 ) + 1 )

Output first day of year

I have various needs for time calculations, but can't get the basic syntax right. The measure
First Day of Year = STARTOFYEAR('Calendar'[Date])
returns 1/1/2019, which is the earliest date on my calendar table. Today's date being Jun 2022, I want it to return 1/1/2022.
Related question: In order to return the first day of the fiscal year (October 1 of the prior year) I would expect something like
First Day of Fiscal Year = STARTOFYEAR(DATEADD('Calendar'[Date],-3,MONTH))
But this returns the same result, 1/1/2019. Desired result is 10/1/2021
If you want it reference this (the current) year, you need the TODAY() function.
eg:
First Day of Year = date(year(TODAY()),1,1)
First Day of Fiscal Year = date(year(today())-1,10,1)
if you want to get the first Date of the year of a table containing more Years you have to filter the date Table:
CALCULATETABLE(STARTOFYEAR('Calendar'[Date]), 'Calendar'[Year]=year(today()))

AWS Quicksight: Display week as a number, grouped by month and not year

I need to display Week as number in AWS QuickSight.I understand, we can do this to get the week numbers: In the field wells, click the format option for the date field and on the left side-panel, enter 'w' in the Custom format field.
The issue is this gives the week number in the year. How do I get week number per month?
You can use calculated fields to calculate it.
It depends how you define "week of month". In a simple case, if you define first 7 days of a month as "week 1", the second 7 days as "week 2", etc, use this formula:
dateDiff(truncDate('MM', mydate), mydate, 'WK') + 1
I do a date-diff (in weeks) between first day of month (truncDate) to input-ed date.
Result:

Compare totals for the same partial date range year-over-year in DAX / Power BI

I'm trying to create a table which shows a sum of monthly values for one year compared to the last year's totals (structured as the screenshot below):
Monthly Comparison
However, the caveat I'm dealing with is comparing the most current month, which will always contain partial month data (unless it's the last day of the month), to the same date range of the previous year. In the screenshot I attached, our data for January 2018 only goes through January 22nd. However, it's comparing it to the full month of January from 2017, whereas we want that total to be January 1st - 22nd, 2017: Value That Needs to be Updated.
I've tried messing around with various MTD and cumulative totals, but I can't seem to get the logic to work while keeping the aggregation to the monthly level. Any idea what type of logic needs to used in order to compare year-over-year totals, but only do a partial sum for the same date range of a month that is currently in progress?
Thanks in advance.
In my short example, this seems to work:
Total Sales LY 2 =
VAR MaxDate = EDATE(CALCULATE(MAX(Sales[Date]);ALL(Sales));-12)
RETURN
CALCULATE(
[Total Sales];
FILTER(SAMEPERIODLASTYEAR('Date'[Date]);'Date'[Date]<=MaxDate)
)
I calculate Total Sales for the same period last year, with the max of the last available sales date this year.
Total Sales LY = Comparing last year full month (wrong)
Total Sales LY 2 = Comparing last year month, with max of last sales date
PBIX file