Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Help!! year filter

Hi, i need help with this stuff. I have 2 graphics where  i need to show the current year in one graphic, and the previus year in the other, but i also have a filter of year. How can i show this?

  • The easiest way is to apply a filter to the specific visuals.

    1. Make sure the filter pane is visible. Select the View ribbon and Filter button if it isn't.
    2. Select the visual you want.
    3. For the date in the visual, select as shown below for the current year. Relative Date filtering is the key here.
    4. Repeat for the other visual, but change it to show "In the last", then 1, then "Calendar year." If you don't change it to "Calendar year" it will give you the last 12 months effectively.

     

     

    BTW, the other solutions provided that talk about date tables and measures is really the way I would prefer to handle it, but applying visual filters can be the fastest, but it will only solve the problem for specific visuals and not provide the other advantages the measures will do once you have a real Date table in your model.

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hey Anonymous 

     

    This is what you are looking for: https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax

     

    Alternatively, you can create another sliver and edit the interations so that one slicer interacts with one visual and the other with the other so that you can show two separate years of your choice according to the two slicers: https://docs.microsoft.com/en-us/power-bi/service-reports-visual-interactions

     

    I have used both methods depending on the needed final result.

3 Replies

  • edhans's avatar
    edhans
    Community Champion

    The easiest way is to apply a filter to the specific visuals.

    1. Make sure the filter pane is visible. Select the View ribbon and Filter button if it isn't.
    2. Select the visual you want.
    3. For the date in the visual, select as shown below for the current year. Relative Date filtering is the key here.
    4. Repeat for the other visual, but change it to show "In the last", then 1, then "Calendar year." If you don't change it to "Calendar year" it will give you the last 12 months effectively.

     

     

    BTW, the other solutions provided that talk about date tables and measures is really the way I would prefer to handle it, but applying visual filters can be the fastest, but it will only solve the problem for specific visuals and not provide the other advantages the measures will do once you have a real Date table in your model.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey Anonymous 

     

    This is what you are looking for: https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax

     

    Alternatively, you can create another sliver and edit the interations so that one slicer interacts with one visual and the other with the other so that you can show two separate years of your choice according to the two slicers: https://docs.microsoft.com/en-us/power-bi/service-reports-visual-interactions

     

    I have used both methods depending on the needed final result.

  • Hey Anonymous ,

     

    this site contains almost anything one has to know about time intelligence and Power BI or better DAX:

    https://www.daxpatterns.com/time-patterns/

     

    It is essential that you create a calendar table, relate the date column of the calendar table to the fact table.

    Use the year columns from the calendar table in your visuals, the slicer and the months.

     

    Create a measure that calculates the previous year value and use this measure in the visual that shows the previous year values.

     

    Hope this will help to tackle your challenge.

     

    Regards,

    Tom