I have a column called Snapshot Effective Period (next month) which is the Nextmonth([Snapshot Period]). This function stops when the snapshot period is 12/1/2021, what I expect to see is 1/1/2022 when the snapshot period is 12/1/2021. The value is not rolling over a year. Any advice?
Snapshot effective period next month c1 is a calculated column in date format.
Snapshot Effective Period (Next Month) c1 = NEXTMONTH('Forecast Detail'[Snapshot Period])
NEXTMONTH function should be used on Calendar
Notes In order to use any time intelligence calculation, you need a
well-formed date table. The Date table must satisfy the following
requirements:
All dates need to be present for the years required. The Date table
must always start on January 1 and end on December 31, including all
the days in this range. If the report only references fiscal years,
then the date table must include all the dates from the first to the
last day of a fiscal year. For example, if the fiscal year 2008 starts
on July 1, 2007, then the Date table must include all the days from
July 1, 2007 to June 30, 2008. There needs to be a column with a
DateTime or Date data type containing unique values. This column is
usually called Date. Even though the Date column is often used to
define relationships with other tables, this is not required. Still,
the Date column must contain unique values and should be referenced by
the Mark as Date Table feature. In case the column also contains a
time part, no time should be used – for example, the time should
always be 12:00 am. The Date table must be marked as a date table in
the model, in case the relationship between the Date table and any
other table is not based on the Date.
https://dax.guide/nextmonth/
Instead of NEXTMONTH use DATE
Snapshot Effective Period (Next Month) c1 = DATE( YEAR('Forecast Detail'[Snapshot Period]), MONTH('Forecast Detail'[Snapshot Period]) +1, DAY('Forecast Detail'[Snapshot Period]))
Related
Hi I am trying to get total YTD amount for last year.
When I select October 2020 my current YTD amount works here is what it looks like :
YTDAmount = TOTALYTD(sum(PCSReport[PD]),PCSReport[PCSMonth])
However, I want to show YTD October 2019 and for some reason it is showing blank. This is the DAX I made :
LYTDAmount = TOTALYTD(sum(PCSReport[PD]), SAMEPERIODLASTYEAR(PCSReport[PCSMonth]) )
Since your calculations are correct, here is what might be the problem.
To work with time intelligence functions (TOTALYTD,DATESYTD ... ) you must have at leat one date table with an active relationship to your fact table.
A date table is a table that meets the following requirements:
It must have a column of data type date (or date/time)—known as the date column.
The date column must contain unique values.
The date column must not contain BLANKs.
The date column must not have any missing dates.
The date column must span full years. A year isn't necessarily a calendar year (January-December).
The date table must be marked as a date table.
I'm having some difficulty getting a YoY change % for values in Power BI. The averages don't come out proper. I've come to understand this is an AVERAGE vs AVERAGEX issue in Power BI.
I need to create charts of year on year growth monthly. So Jan20 % change from Jan 19. I thought what was below was correct, but it is always throwing an issue for the month of February and a few other months. But some of the months are correct. My Measure is below.
Growth =
IF(
ISFILTERED('Oct5_5'[TRAFFIC_DTE]),
ERROR("Check Time Filter."),
VAR PrevMonth =
CALCULATE(
AVERAGE('Oct5_5'[VISITS_AMT]),
DATEADD('Oct5_5'[TRAFFIC_DTE].[Date], -12, MONTH)
)
RETURN
DIVIDE(
AVERAGE('Oct5_5'[VISITS_AMT]) - PrevMonth,
PrevMonth
)
)
Snippet
Can someone please show me how to use the right Average? Thank you so much!
Do You have all calendar days in your traffice_dte?
Probably not. This causes you to go back to a date that does not exist, which causes an error.
DATEADD function work ok if you use it on "calendar" tabel.
Requirement below:
https://dax.guide/dateadd/
The Date table must always start on January 1 and end on December 31, including all the days in this range. If the report only references fiscal years, then the date table must include all the dates from the first to the last day of a fiscal year. For example, if the fiscal year 2008 starts on July 1, 2007, then the Date table must include all the days from July 1, 2007 to June 30, 2008.
There needs to be a column with a DateTime or Date data type containing unique values. This column is usually called Date. Even though the Date column is often used to define relationships with other tables, this is not required. Still, the Date column must contain unique values and should be referenced by the Mark as Date Table feature. In case the column also contains a time part, no time should be used – for example, the time should always be 12:00 am.
The Date table must be marked as a date table in the model, in case the relationship between the Date table and any other table is not based on the Date.
I have a table containing a date field (from 1 March 2020 to now) that I need to filter to a specific date and the previous 6 days to give complete week's data. So if I chose 30 March I'd get a table of 24 March to 30 March. If I then chose 31 March the table would show 25 March to 31 March.
I can use a date slicer to choose a range of dates but I want to be able to pick a single date, with Power BI automatically selecting the earlier date.
Any pointers much appreciated.
Mark.
You can create two measure - one for Slicer selected date and Another one with 7 day minus from the selected date as below-
Considering your date table name is- Dates
selected_date = SELECTEDVALUE(Dates[Date])
seven_day_starts_from = DATEADD(Dates[Date],-7,DAY)
Now create your calculated measure first like-
total_sales = SUM(Sales[sale])
Here comes how you will always calculate last 7 days sales considering the selected date in the slicer-
7_day_sales =
(
CALCULATE(
[total_sales],
DATESBETWEEN(
'Dates'[Date],
[seven_day_starts_from],
[selected_date]
)
) + 0
)
Remember, this is just a sample flow showing how it should work. You should try to follow the steps with your data and table structure. Dates table is a calendar table and Sales table is connected to the Dates table using the Date column.
I am creating a report with buttons that use a slicer to show the last 3 calendar months, the default view, and YTD. The first two are all set and will continue to work fine, however i am having trouble with the YTD filter because i need it to exclude the current month (some of the key metrics for this slicer are only accurate monthly, even thought the data is updated Daily). Any idea how to accomplish this without me having to manually change it every month? An example of it working today would show me 2020 through August, since September is not complete. September would be included in the filter starting October first. I am thankful for your help/insights!
I typically build a calculated column on my date table called something like "Date in Range", that looks something like the below. You could also apply this to a date in a normal table if you are not using a date dimension.
Date in Range = IF ('MyTable'[Date] <
DATEADD(TODAY(), -1 * DAY(TODAY()), day),
1,
0)
This compares the date in the table row with TODAY(), e.g. 14 Sep 2020, minus the day of the month of today (14), effectively getting you back to the start of the current month. This will then return 1 for dates before the end of last month or 0. Filter on 1 or 0 to get your result (or use something more meaningful in place of the 1 or 0).
I've a requirement where I need to compare a column date with current date. If my column date > last sunday's date I need to populate a status. Here, am facing issues in calculating present week's sunday date.
I need to calculate Previous Sunday's date in Informatica expression transformation.
I am not exactly sure about your requirement, however, you can always get the day and based on that subtract a fixed number of days to reach any sunday you want (present week or previous week). You should have a limited (7) set of IIF statements to achieve this.
Eg. If the day is 'Tuesday' (day of the current date) then subtract 2 from the date to get sunday date!
You can write an expression as- trunc(sysdate,'d') in a variable port which is having datatype as date.
The expression would return the Sunday date of the current date. Then you can compare the two dates (your column date and the variable port date) and populate the status.
If you just want to verify the result of the expression trunc(sysdate,'d') you can fire the following query in the oracle db:
"select trunc(sysdate,'d') from dual"
result returned would be the latest Sunday date.