Power BI previous year and Previous month in same column date hierarchy - powerbi

I want to get the revenue data by the department to see the current month vs previous month comparison, what I also want is that when the data is rolled up to year it should show me the previous year data, which I am not able to achieve.
enter image description here
If you look at the image I am getting the previous month sales with respect to the current month but for year 2021 I see the data for December 2020 but I need 1,09.900 instead.
I tried Summarize function and other date function but am not able to achieve the data in required format as below
enter image description here

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 :)

Unable to get previous year value on summarization/rollup along with previous month

I have dimension tables fct_department, Date and fact table fct_billing. I want to get the sum of fct_billing_amount for each month of the year for the list of department and fct_billing_amount for the previous month. For example if I have fct_billing_amount as $12,000 for the Month of Nov 22, I also want to see the value for fct_billing_amount, which is $10,000 for the previous month. But when the fct_billing_amount data for the listed department is rolled-up or summarized to year, I should get the value for the year 2022 which is $1,20,000 along with the total of fct_billing_amount for the year 2021 which is $1,10,000 which is for the previous year.I am trying to achieve the output in Power BI. The required out should be as mentioned in the image Required output

How to create a YTD using fiscal year / financial year

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

How to filter YTD to last complete month in Power BI

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).

How to extract Month and Year from column in PowerBI powerquery

I have a column (monthyear) in the image below. I want to extract the Month and year from the column to put it in the new column. Note: In my dataset this information goes for every day of the year
So the new column would look like:
01/2020
01/2020
01/2020
etc.
In Power Query, use some of the date functions.
To get the year it will be
Date.Year([monthyear])
For the month, it will depend on how you want to format it. Using the month of June as an example:
To get 'Jun'
Date.ToText([monthyear],"MMM")
To get the month number in the format 06
Number.ToText(Date.Month([monthyear]), "00")
Just to get the number 6 it will be:
Date.Month([monthyear])
In DAX use the date functions
For year the calculated column will be:
YEAR([monthyear])
For the month:
MONTH([monthyear])
I would always do a much data transformation in Power Query when you can before it gets to the data model.