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
lg1551
Resolver II
Resolver II

Need Total YTD for Selected Year - Ignore Month and Quarter

I thought this would be fairly simple but I'm not having any success with this metric.

 

I have a hierarchal date selection slicer that includes Fiscal Year, Fiscal Quarter, and Fiscal Month. I have one column with a margin % which responds to the date selection slicer. This is working as expected.

 

I need another column of this same margin % which will calculate the selected Fiscal Year in the slicer and ignore the Fiscal Quarter and Fiscal Month selections, so it always displays the full margin % for the year, regardless of what is selected in Fiscal Quarter and/or Fiscal Month.

 

I've tried, ALL, I've tried REMOVEFILTERS, and other approaches I've found in the forum and elsewhere but it does not calculate properly. It either continues to respond to the date selection or it filters all data for all years. I have even created a duplicate date table with no luck.

 

Can anyone advise?

 

1 ACCEPTED SOLUTION

Hi @lg1551 ,

 

Please try this measure.

fixed_Margin % = 
var a =SELECTEDVALUE('date'[Date].[Year])
return  
IF(YEAR(MAX('Table'[date]))=a,CALCULATE('Table'[your measure ],FILTER(ALL('Table'),YEAR('Table'[date])=a)),BLANK())

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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-tangjie-msft
Community Support
Community Support

Hi @lg1551 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.

vtangjiemsft_0-1681712128718.png

vtangjiemsft_1-1681712143038.png

 

(2) We can create two measures. 

Margin % YTD = 
var _a=CALCULATE(SUM('Table'[Margin]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(MAX('Table'[date]))))
var _b=CALCULATE(SUM('Table'[sales]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(MAX('Table'[date]))))
RETURN
_a/_b
_Margin % YTD = 
var a =SELECTEDVALUE('date'[Date].[Year])
return  
IF(YEAR(MAX('Table'[date]))=a,CALCULATE('Table'[Margin % YTD],FILTER(ALL('Table'),YEAR('Table'[date])=a)),BLANK())

(3) Then the result is as follows.

vtangjiemsft_2-1681712207686.pngvtangjiemsft_3-1681712226367.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

I probably should have clarified better in my remarks. The margin % I refer to is a measure, not a column from a data table. I am using it as a column in a matrix visualization.

Hi @lg1551 ,

 

Please try this measure.

fixed_Margin % = 
var a =SELECTEDVALUE('date'[Date].[Year])
return  
IF(YEAR(MAX('Table'[date]))=a,CALCULATE('Table'[your measure ],FILTER(ALL('Table'),YEAR('Table'[date])=a)),BLANK())

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

 

lg1551
Resolver II
Resolver II

Here are some tables to illustrate the functionality I want:

 

Full Year SelectedFull Year Selected Q1 SelectedQ1 Selected Q1 - Month 2 SelectedQ1 - Month 2 Selected
Margin % YTDMargin % Margin % YTDMargin % Margin % YTDMargin %
98%98% 98%130% 98%146%

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.