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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dgwilson
Resolver III
Resolver III

IF statement unexpected result evaluation

The goal here is to remove a very tiny piece of hard coding so that this measure never needs to be touched again. The measure returns a year to date sum on revenue.

It works if the year is hard coded.

It does not work if the year is another measure. I can with certainty say that the measure [Fiscal Year TY] is returning 2019 as a Whole Number.

 

I'm seeking recommendations on what I should do next.

 

_Revenue TY =

    VAR reportMonth = [Report_Month]
    VAR fiscalYear = 2019                        // this works and is returning a value that charts correctly on a line graph (July, August, September)
//    VAR fiscalYear = [Fiscal Year TY]           // returns the value (total) – it does not chart on a line graph (only shows a “dot” for the last month).

RETURN
CALCULATE(TOTALYTD(SUM(EVO_DMT_BUS_CUST_PROFIT_VW[_Revenue]), 'Calendar'[Date], "30 June"), 'Calendar'[Fiscal Year]=fiscalYear, ALL(EVO_DMT_BUS_CUST_PROFIT_VW[RPT_MONTH]), EVO_DMT_BUS_CUST_PROFIT_VW[RPT_MONTH] <= reportMonth)

The results I am receiving are below (the aqua line shoudl be ignored - that's the previous year and another (similar) calculation.

2019-07-04 09_12_37-Customer Profitability Hard Coding FiscalYear 2.png2019-07-04 09_12_37-Customer Profitability Hard Coding FiscalYear 1.png

1 ACCEPTED SOLUTION

@GilbertQ 

 

Good news! I've been able to figure out that I had a fault in on of my measures.

 

 

Fiscal Year TY = 
    var report_FY_Year = CALCULATE(MAX('Calendar'[Fiscal Year]), FILTER(ALL('Calendar'), 'Calendar'[Date] = [Report_Month]))
RETURN
    report_FY_Year

 

The Fiscal Year calculation did not have ALL('Calendar') in the filter. So when I was convinced that it was returning 2019... it was not necessarily in all cases as it worked through July thru June.

 

This meant that when I used it in Revenue YTD the measure kept changing on me.

 

 

_Revenue_YTD = 
    VAR reportMonth = [Report_Month]
  VAR fiscalYear = [Fiscal Year TY]
    VAR YTD_Revenue = CALCULATE(Data[_Revenue], DATESYTD('Calendar'[Date], "30 June"), FILTER(ALL('Calendar'), AND('Calendar'[Fiscal Year]=fiscalYear, 'Calendar'[Date] <= reportMonth)))
RETURN
YTD_Revenue

 

This measure does give me the expected results now.

 

- David

 

View solution in original post

12 REPLIES 12

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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