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
KH_Mike
Helper III
Helper III

Calculate Annual Result in Table which contain Date column

Hi All,

 

I have a data table and would like to show the "Annual Result" like below. Right now, I can use DAX to calculate the YTD result by Fiscal Year "calculate(sum(Table[Result]),DATESYTD(Table[Date],"03/31"))". I want to know is it possible to show the "Annual Result". I try serval DAX express and not able to show like below. Anyone can give me hints .... Thank you.



 

DateResultYTD (Fiscal Year)Annual Result
2020-041178
2020-052378
2020-063678
2020-0741078
2020-0851578
2020-0962178
2020-1072878
2020-1183678
2020-1294578
2021-01105578
2021-02116678
2021-03127878
2021-0433102
2021-0547102
2021-06512102
2021-07618102
2021-08725102
2021-09833102
2021-10942102
2021-111052102
2021-121163102
2022-011275102
2022-021388102
2022-0314102102
2022-049955
2022-05101955
2022-06113055
2022-07124255
2022-08135555
1 ACCEPTED SOLUTION

Hi, @KH_Mike 

If you want to keep the slice filtter you select, you just need to replace the ALL() function to ALLSELECTED() function(), like this:

Measure = var _current_date= SELECTEDVALUE('Sheet1'[Date])
var _month = MONTH(_current_date)
 return 
IF(_month>= 4,CALCULATE(SUM('Sheet1'[Result]), FILTER(ALLSELECTED('Sheet1') , 'Sheet1'[Date]>= DATE( YEAR(_current_date),4,1) && 'Sheet1'[Date] <=DATE( YEAR(_current_date)+1,3,31))) ,  CALCULATE(SUM('Sheet1'[Result]), FILTER(ALLSELECTED('Sheet1') , 'Sheet1'[Date]>= DATE( YEAR(_current_date)-1,4,1) && 'Sheet1'[Date] <=DATE( YEAR(_current_date),3,31)))   )

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
v-yueyunzh-msft
Community Support
Community Support

Hi, @KH_Mike 

Here are the steps you can follow:

(1)This is my test data, it is the same as you:

vyueyunzhmsft_0-1664261308139.png

(2)You can create a measure:

Measure = var _current_date= SELECTEDVALUE('Sheet1'[Date])
var _month = MONTH(_current_date)
 return 
IF(_month>= 4,CALCULATE(SUM('Sheet1'[Result]), FILTER(ALL('Sheet1') , 'Sheet1'[Date]>= DATE( YEAR(_current_date),4,1) && 'Sheet1'[Date] <=DATE( YEAR(_current_date)+1,3,31))) ,  CALCULATE(SUM('Sheet1'[Result]), FILTER(ALL('Sheet1') , 'Sheet1'[Date]>= DATE( YEAR(_current_date)-1,4,1) && 'Sheet1'[Date] <=DATE( YEAR(_current_date),3,31)))   )

(3)Then we can put this measure in the visual and we can meet your need, the result is as follows:

vyueyunzhmsft_1-1664261463388.png

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @v-yueyunzh-msft 

 

Thank you for your support. It do come out the expected result. However, my dataset also contain certain column like "Product", "Region", "Country" ...... etc.

It seems that your DAX express will not be caculate according to my selection on slicer. Any ideas how to handle it? Thank you.

Hi, @KH_Mike 

If you want to keep the slice filtter you select, you just need to replace the ALL() function to ALLSELECTED() function(), like this:

Measure = var _current_date= SELECTEDVALUE('Sheet1'[Date])
var _month = MONTH(_current_date)
 return 
IF(_month>= 4,CALCULATE(SUM('Sheet1'[Result]), FILTER(ALLSELECTED('Sheet1') , 'Sheet1'[Date]>= DATE( YEAR(_current_date),4,1) && 'Sheet1'[Date] <=DATE( YEAR(_current_date)+1,3,31))) ,  CALCULATE(SUM('Sheet1'[Result]), FILTER(ALLSELECTED('Sheet1') , 'Sheet1'[Date]>= DATE( YEAR(_current_date)-1,4,1) && 'Sheet1'[Date] <=DATE( YEAR(_current_date),3,31)))   )

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @v-yueyunzh-msft 

 

Thank you. You save my life.

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.