Forum Discussion

Tlotly's avatar
Tlotly
Helper V
5 years ago
Solved

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 

  • Tlotly,

     

    Try this measure:

     

    Test = 
    IF (
        ISFILTERED ( 'Calendar'[Fiscal Year] ),
        [Errors],
        CALCULATE (
            [Errors],
            'Calendar'[Fiscal Year] = YEAR ( TODAY () )
        )
    )

     

     

  • Tlotly,

     

    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
        vResult

     

    In 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

  • Tlotly,

     

    Try this measure:

     

    Test = 
    IF (
        ISFILTERED ( 'Calendar'[Fiscal Year] ),
        [Errors],
        CALCULATE (
            [Errors],
            'Calendar'[Fiscal Year] = YEAR ( TODAY () )
        )
    )

     

     

    • Tlotly's avatar
      Tlotly
      Helper 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?

      • DataInsights's avatar
        DataInsights
        Super User

        Tlotly,

         

        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
            vResult

         

        In 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.

  • Thank you DataInsights , it worked. I just did a little correction on the formula, included  year before 

    year('Calendar'[Date] = TODAY ())