How to create a YTD using fiscal year / financial year - powerbi

Apologises if this question has already been raised but I'm struggling with my data model to create a rolling total / YTD sales using fiscal years.
I know PowerBI/DAX is great using calendar Jan-Dec dates but how do you amend this if your financial year begins in March-April instead?
When I created my calendar table, I used the CALENDEARAUTO() which gave me a column of dates from Jan to Dec as expected and when I change the function to CALENDERAUTO(3), my date column begins from March to April which makes sense.
However, if I use the CALCULATE and DATESYTD functions to sum the total sales column and choose the date column as described above, the result looks like:
Actual YTD = CALCULATE(sum('spend'[Actual]),DATESYTD('Fiscal Year Table'[Date],"03-31"))
What do I need to do exactly for it work in this exact date format?
Many thanks
Hash

Related

DAX: Projected sum for all months greater than current month of current year

I have a requirement to filter a sum of projected sales for all months >= current month of the current year and any subsequent years that we have project sales data for.
So for 2023 I'd need the sum of projected sales for only February (the current month) through December 2023 on.
My DAX below accomplishes this accurately for current year OR current month, but I can't seem to filter by both without the results including all prior years. Client wants to see past sales and projected sales in the same visual so I cannot just filter out the prior years.
CURRENT SUM OF SALES = CALCULATE(SUM('Table'[Sales]), FILTER('DateTable', YEAR('DateTable'[Date]) >= YEAR(TODAY())))
Thank you for any help!
First, let me answer your request on writing a DAX that filters all months >= current month of the current year; you should create your date as follow:
DATE(YEAR(NOW()),MONTH(NOW()),1)
Then add it to your measure as follow:
CURRENT SUM OF SALES = CALCULATE(SUM('Table'[Sales]), FILTER('DateTable', 'DateTable'[Date] >= DATE(YEAR(NOW()),MONTH(NOW()),1)))
Second, regarding your concern about your client wanting to see past sales and projected sales in the same visual, you only have to create another measure that shows past sales.
If I understand your table structure correctly, this month's sales value will be updated to the actual value when your ETL refreshes the data next month; if not, please let me know.
If my assumption is valid, you can write Past Sales - measure as follows:
Past Sales = CALCULATE(SUM('Table'[Sales]), FILTER('DateTable', 'DateTable'[Date] < DATE(YEAR(NOW()),MONTH(NOW()),1)))
Then, use both measures in a Line chart with the 'DateTable'[Date] column as the X-axis.
I hope I helped in a way; if so, please mark this as an answer and vote for it :)

Dax TotalYTD and SamePeriodLastYear Not working

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.

Power BI growth rate calculation YoY

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.

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

Calculate revenue by week - sunday to saturday (last year) on tabular cube/Power BI

I have a report on Power BI where data comes from a tabular cube. The DAX expressions are made in the cube. When drilling down in Power BI and comparing results to the original numbers there is a slight difference. Power BI calculates the week figures as monday - sunday, but I want it to show from sunday - saturday
Initial code:
IF(ISBLANK([Revenue]), BLANK(), CALCULATE([Revenue],SAMEPERIODLASTYEAR('Date'[Date]),ALL('Date'[Date])))
The date table in cube contains columns [SortFiscalWeek], [SortFiscalMonth], [SortFiscalYear], [Week Commencing],Fiscal Week Number.
Week Commencing is in accordance to Sunday (being the week commence date) - Saturday.
The sort fiscal columns start as 1 from years ago and end to whichever number it is today based on today's date.
I added Fiscal Week Number as I thought it might be helpful and tried using it as Test New Users LY = IF(ISBLANK([New Users]),BLANK(),CALCULATE([New Users],SAMEPERIODLASTYEAR('Date'[Date]),FILTER(ALL('date'),'Date'[Fiscal Week Number]='Date'[Fiscal Week Number]&&'Date'[YearInt] = 'Date'[YearInt]-1)))
EDIT
In Power BI I am using a Clustered Column Chart with Date Hierarchy in the Axis and Revenue in the Value. On week level it sums the Revenue as Monday-Sunday and not Sunday-Saturday. Hope this clears up some doubt as to how i am using the data in Power BI
Can anyone help?
If I understood well, I had the same problem, I created a calculated column giving me the name of the month, like this:
MonthName = SWITCH(DimDate[Month], 1,"gennaio",2,"febbraio",3,"marzo",4,"aprile",5,"maggio",6,"giugno",7,"luglio",8,"agosto",9,"settembre",10,"ottobre",11,"novembre",12,"dicembre","altro")
then I needed to order the month by month number, so to do this you need to select your calculated column, and then go to the tab Modelling>Sort by column, in this menu you can choose on which field of the table you order the selected field.
Hope that helps.