Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Dallas7890
Resolver I
Resolver I

Calculation group for Previous FY duplicating values when the Month is in the X Axis - Not sure why?

I created a calculation group in my Power BI model to analyze overtime hours. This calculation group includes measures for:

  • Current Hours
  • Same Period Last Year (SPLY)
  • Previous Fiscal Year (FY)

Additionally, I implemented a Field parameter to dynamically change the Axis of my visuals. This parameter allows for the selection of various time periods, such as:

  • Fiscal Year (FY)
  • Month
  • Date
  • Start of Week
  • Day

The Problem is the setup works well in a Clustered column chart for most time periods, but I'm encountering an issue when selecting "Month" as the Axis. Specifically, the measure for the Previous FY displays the same value for each month, instead of showing distinct values for each month.

In the Clustered Column chart
In the X-axis - I put the Select Axis - which is just another Field parameter that is for the OT Type Parameter = Total Overtime Hours, Total Overtime Hours Weekday, Total Overtime Hours Weekend, etc...
In the Y-axis I put the OT Type Parameter - which again is just another Field Parameter that allows me to select by Director, City, Supervisor, Cost center, Affiliation, Employee.
In the Legend I put the Time Calculation that allows me to select between Current, SPLY, Previous FY.

Here is the measure I'm using in the Calculation group for the Previous FY:
Previous FY = CALCULATE(SELECTEDMEASURE(), PREVIOUSYEAR('Calendar'[Date]))

For reference, our fiscal year runs from April 1, 2023, to March 31, 2024.

I can't share the data due to confidentiality but I tried to give as much details as possible. 


1 ACCEPTED SOLUTION

Hi Owen,

 

I actually managed to solve the FY month issue with this measure. It seems to work okay, was it the best way, not sure. Thanks again for replying and have a great day. 

Previous FY =
VAR CurrentDate = MAX('Calendar'[Date])
VAR CurrentYear = YEAR(CurrentDate)
VAR CurrentMonth = MONTH(CurrentDate)
VAR PreviousFiscalYearStartYear = IF(CurrentMonth >= 4, CurrentYear - 1, CurrentYear - 2)
VAR PreviousFiscalYearMonth = IF(CurrentMonth >= 4, CurrentMonth, CurrentMonth + 12)
VAR PreviousFiscalMonthStart = DATE(PreviousFiscalYearStartYear, PreviousFiscalYearMonth, 1)
VAR PreviousFiscalMonthEnd = EOMONTH(PreviousFiscalMonthStart, 0)
VAR PreviousFiscalYearStartDate = DATE(PreviousFiscalYearStartYear, 4, 1)
VAR PreviousFiscalYearEndDate = DATE(PreviousFiscalYearStartYear + 1, 3, 31)
RETURN
    IF(
        HASONEVALUE('Calendar'[Month]),
        CALCULATE(
            SELECTEDMEASURE(),
            DATESBETWEEN('Calendar'[Date], PreviousFiscalMonthStart, PreviousFiscalMonthEnd)
        ),
        CALCULATE(
            SELECTEDMEASURE(),
            DATESBETWEEN('Calendar'[Date], PreviousFiscalYearStartDate, PreviousFiscalYearEndDate)
        )
    )

View solution in original post

4 REPLIES 4
OwenAuger
Super User
Super User

Hi @Dallas7890 

PREVIOUSYEAR always returns a complete year preceding the year of the minimum date filtered. "Year" means calendar year unless the 2nd argument is provided, which should possibly be "03/31" in your case.

 

So for each month within in the same year, the Previous FY calculation item would be expected to return the same result.

 

Could you mock up a table showing what you would expect the Previous FY calculation item to return when you have chosen the Month field parameter value?

 

Also, what difference do you expect between Same Period Last Year and Previous Fiscal Year?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

DateOvertime Hours
4/15/20235
5/10/20238
6/20/20236
7/5/20237
8/18/20234
9/12/202310
10/3/202312
11/25/202315
12/13/20239
1/8/202414
2/17/202411
3/29/20243
  
  
  
  

Month

Previous FY OT Hrs
April5
May8
June6
July7
August4
September10
October12
November15
December9
January14
February11
March3

 

Hi Owen, Thanks for replying. Currently when Selecting the following Calculations for Current and Previous FY and then on Month as the Axis it just repeats the same FY amount for each month. It works okay when I select the other Field Parameter Axis below for Shift Date, Start of Week and Day but it repeats when Month?Mois is selected. I tried to also hard code the Fiscal year start and end date but it still does the same thing. I would like it to show the total amount for each month for the last FY not the entire FY amount. 

I hope this helps explain my dilemma a bit better and I really appreciate your help with this

Thank you kindly,

Dallas7890_0-1722773144855.png

Dallas7890_1-1722773197114.png

This shows the amount with SPLY vs Previous FY 

Dallas7890_0-1722781415799.png

 

Even if I choose the Fiscal Year 2023-24 from the slicer up top. It still repeats the Previous FY repeats

Dallas7890_1-1722781711663.png

 

Dallas7890_2-1722781727164.png

 





 

 

Thanks for the extra detail 🙂

A few questions:

  1. If you instead choose SPLY instead of Previous FY, do you see the expected monthly values for the previous year?
    (I'm assuming SPLY uses SAMEPERIODLASTYEAR or equivalent.)
  2. Could you show me the code for these:
    • The field parameter table (assuming it's created with DAX)
    • All of the calculation items in the Time Parameter calculation group
  3. Is your 'Calendar' table marked as a date table?

General comments

  • My main observation would still be that PREVIOUSYEAR is expected to shift the date filter to the complete previous year.
  • So the Previous FY results are actually what I would expect when you select Month on the field parameter.
  • However the results are not what I would expect when you select Shift Date, Start of Week and Day (though they are the results you want to see in the report).

 

If you could post a copy of a PBIX with sanitised data (OneDrive or other cloud storage link), I think that would be a great help in solving this 🙂

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi Owen,

 

I actually managed to solve the FY month issue with this measure. It seems to work okay, was it the best way, not sure. Thanks again for replying and have a great day. 

Previous FY =
VAR CurrentDate = MAX('Calendar'[Date])
VAR CurrentYear = YEAR(CurrentDate)
VAR CurrentMonth = MONTH(CurrentDate)
VAR PreviousFiscalYearStartYear = IF(CurrentMonth >= 4, CurrentYear - 1, CurrentYear - 2)
VAR PreviousFiscalYearMonth = IF(CurrentMonth >= 4, CurrentMonth, CurrentMonth + 12)
VAR PreviousFiscalMonthStart = DATE(PreviousFiscalYearStartYear, PreviousFiscalYearMonth, 1)
VAR PreviousFiscalMonthEnd = EOMONTH(PreviousFiscalMonthStart, 0)
VAR PreviousFiscalYearStartDate = DATE(PreviousFiscalYearStartYear, 4, 1)
VAR PreviousFiscalYearEndDate = DATE(PreviousFiscalYearStartYear + 1, 3, 31)
RETURN
    IF(
        HASONEVALUE('Calendar'[Month]),
        CALCULATE(
            SELECTEDMEASURE(),
            DATESBETWEEN('Calendar'[Date], PreviousFiscalMonthStart, PreviousFiscalMonthEnd)
        ),
        CALCULATE(
            SELECTEDMEASURE(),
            DATESBETWEEN('Calendar'[Date], PreviousFiscalYearStartDate, PreviousFiscalYearEndDate)
        )
    )

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.