DAX formula to calculate the full year total for the previous financial year, based on page filter selection

peejay

Board Regular
Joined
Jul 11, 2003
Messages
83
I am trying to calculate Total Revenue for the full financial year (ending 30 Jun) preceding the month selected in a filter using my Data Table's Month End field. I've wasted a lot of time on something which seems (and probably is) straight forward for the experienced DAX user (I'm a relative newbie to DAX).

I have a Revenue table (with Month End date field) related to my tblDataTable on my [Month End] column.
My PBI page has a filter using the tblDateTable[Month End], where the user selects a single month end.

When they select (eg) March 2018, I want to generate a Total Revenue for FY17 (ie Jul16 to Jun17).

My most recent crack at this is as follows:

<PRE>

LastDate:=LASTDATE(tblDateTable[Month End])
StartDate:=IF(MONTH([LastDate])>=7,
EOMONTH([LastDate], -(MONTH([LastDate])+6))+1,
EOMONTH([LastDate], -(MONTH([LastDate])+18))+1
)
EndDate:=IF(MONTH([LastDate])>=7,
EOMONTH([LastDate], -(MONTH([LastDate])-6)),
EOMONTH([LastDate], -(MONTH([LastDate])+6))
)

Rev LY Full Yr:=CALCULATE(
[Revenue],
ALL(tblDateTable[Month End]),
FILTER(
VALUES(tblDateTable[Month End]),
([StartDate] <= [LastDate] && [LastDate] <= [EndDate])
)
)</PRE>

[Revenue] is a measure, being SUM([Net Revenue].
tblDateTable[Month End] is my Month End column in my date table.

I am trying to reset the [Month End] page filter, and replace it with all the months falling between Jul16 to Jun17.

My LastDate gives me the most recent month end value in the filter, and the StartDate gives me the 1st day of the prior financial year and EndDate the last day of the prior financial year.

However, the Rev LY Full Yr measure gives me (blank) for all dates.

I think I'm almost there but I'd be really appreciative if someone could help me solve this and put me out of my DAX misery.

Thanks, PJ
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
All this stuff is super hard work without a decent calendar table. I don't know to what extent your tblDateTable is set up to help, but if it's not I think you should make it so that it is.

For example, the calendar table might have columns like:

Month End
Calendar Year
Calendar Quarter
Fiscal Year
Fiscal Quarter
etc etc

In particular, the Fiscal Year should be based on the 30 June year end. So for all months from July 2016 to June 2017 the Fiscal Year column should just read "2017". July 2015 to June 2016 would just read "2016". You can add a calculated column with some logic to do this if you can't create at the query step.

Then the formula is something like:

Code:
Rev LY Full Yr:=
CALCULATE(
   [Revenue],
   FILTER (
      ALL( tblDateTable ),
      tblDateTable[Fiscal Year] = MAX ( tbleDateTable[Fiscal Year] ) -1
   )
)
 
Upvote 0
Or, if you really just want to solve this particular issue...

Code:
Rev LY Full Yr:=
CALCULATE(
   [Revenue],
   PREVIOUSYEAR ( tblDateTable[Month End]), "30/06/2017" )
)
 
Upvote 0
Thanks Gazpage

This has done the job - MANY thanks for your help.
I already had an expansive date table and had tried using my Fiscal Year field but got nowhere - most likely due to my inexperience with the FILTER command.

But thanks to your help I can now move on with my Power BI life :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top