Forum Discussion
Display current year values on the chart
Good day
Please see attached, I need to display only the current year i.e. 2021 on the matrix on the attached example . So basically if the year is not selected, I only want to display the current year and not both years.
See the link to the exampkle below:
https://www.dropbox.com/s/5eq9hcnor7udthg/CurrentYearError.pbix?dl=0
Thanks
Matlotlo
Try this measure:
Test = IF ( ISFILTERED ( 'Calendar'[Fiscal Year] ), [Errors], CALCULATE ( [Errors], 'Calendar'[Fiscal Year] = YEAR ( TODAY () ) ) )Try this measure:
Test = VAR vCurrentFiscalYear = CALCULATE ( MAX ( 'Calendar'[Fiscal Year] ), 'Calendar'[Date] = TODAY () ) VAR vResult = IF ( ISFILTERED ( 'Calendar'[Fiscal Year] ), [Errors], CALCULATE ( [Errors], 'Calendar'[Fiscal Year] = vCurrentFiscalYear ) ) RETURN vResultIn the test pbix, no data is returned because the Calendar table ends on 2021-06-30. Be sure to mark the Calendar table as a date table.
4 Replies
- DataInsightsSuper User
Try this measure:
Test = IF ( ISFILTERED ( 'Calendar'[Fiscal Year] ), [Errors], CALCULATE ( [Errors], 'Calendar'[Fiscal Year] = YEAR ( TODAY () ) ) )- TlotlyHelper V
DataInsights thank you.
It works perfectly but now I have a bummer. I'm working with fiscal dates i.e. Jul- Jun, meaning when I load new dates which is from 01 July 2021, I might not get the correct results since the dates will fall under the new fiscal year 2022 and here we are comparing with today's date. Is there a way of working around this?
- DataInsightsSuper User
Try this measure:
Test = VAR vCurrentFiscalYear = CALCULATE ( MAX ( 'Calendar'[Fiscal Year] ), 'Calendar'[Date] = TODAY () ) VAR vResult = IF ( ISFILTERED ( 'Calendar'[Fiscal Year] ), [Errors], CALCULATE ( [Errors], 'Calendar'[Fiscal Year] = vCurrentFiscalYear ) ) RETURN vResultIn the test pbix, no data is returned because the Calendar table ends on 2021-06-30. Be sure to mark the Calendar table as a date table.
- TlotlyHelper V
Thank you DataInsights , it worked. I just did a little correction on the formula, included year before
year('Calendar'[Date] = TODAY ())