Total revenue by fiscal year and total revenue by last fiscal year - powerbi

I have an items table and a date table.
The item table contains all sales data, date sold, price per unit, unit sold, total price.
I have a date table also linked with date sold column on items table.
I would like to calculate total fiscal revenue and fiscal year on year revenue.
The fiscal year starts on 01 july and ends on 30 June.
Regards,
Alex

Related

Month field is not getting drill down in power bi

I am calculating total revenue over the years.
There are two tables calendar and sales. I have calculated total revenue using DAX now I want to display total revenue in each year.
The month field is not getting filtered for the Revenue column, I have attached a snip for reference.
Total revenue(DAX)= total revenue = SUMX(AW_Sales,AW_Sales[OrderQuantity] * RELATED(AW_Products_Lookup[ProductPrice]))

Calculate cumulative sum from beginning of year to filter selection

I have two tables
Calendar - Contains columns for year, quarter, YearQuarter
Sales - contains columns for Entity sold, sale price, date of sale, quarter of sale, year of sale.
I have a filter in my dashboard for Year and Quarter. I would like to create a measure that calculates the cumulative sum of sales from the beginning of the selected year to the selected quarter.
e.g. if Year = 2020, and Quarter = Q3, the measure should calculate the sum of sales from the beginning of 2020 until the end of Q3 2020.
If you had a well-formed date table, you could use time-intelligence functions DATESYTD or TOTALYTD as explained in The hidden secrets of TOTALYTD.
However, your calendar table doesn't qualify, so you need to do things a bit more manually.
Sales YTD =
VAR SelQtr = SELECTEDVALUE ( Calendar[Quarter] )
RETURN
CALCULATE (
[Sales],
ALLEXCEPT ( Calendar, Calendar[Year] ),
Calendar[Quarter] <= SelQtr
)
This removes any calendar filtering except for the year and filters for quarters up to the selected quarter.

How to include QTD and YTD in Redshift query

I am working on SQL script in Redshift. As per the requirements, I have to show the month but the amounts need to be calculated QTD and YTD. How to ignore month dimension from the calculation and how to have YTD calculation for each month?
Example:
Month February: I need to show sum of amount for Jan and Feb as QTD and YTD
Month June: I need to show sum of amount April, May and June in QTD and Jan-June in YTD
ETC.
In selection, I need to show month, year with other dimension.

Grand Total not working for sales per day last year function

I am trying to do a sales by day comparison where I compare the sales this year with the sales of the same day last year as a date of the week.
So I would be comparing Monday March 25 2019 with Monday march 24 2018 etc
Here is the formula I’m using for last year’s sale
Amount per Day LY = CALCULATE([Amount TY], FILTER(all(Dates), Dates[Date] = MAX(Dates[Date])-364))
However, my total isn’t working right for my sales last year. It will just be the total for 1 day (and that day seems to change as my date range increases)
Because you are having a one to one, you can do this with LookupValue:
SalesLY = LOOKUPVALUE(Sheet1[Sales];Sheet1[Date];DATEADD(Sheet1[Date];-364;DAY))
However if you have more rows for the same date, this will not hold, in this case you need to sum all the dates together,
SalesLY = CALCULATE(SUM(Sheet1[Sales]);FILTER(Sheet1; DATEADD(Sheet1[Date];364;DAY)= EARLIER(Sheet1[Date])))
Using DateAdd fixed my problem
Amt per Day LY = CALCULATE([Amount TY], DATEADD(Dates[Date], -364,DAY))

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