Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic selection and filtering on Chart

Hi, I've a requirement to show last 3 years data based on user selection. So, If a user selects 'Reporting Period' as 2019.Q2 then i want values of 2019.Q2, 2018.Q2, 2017.Q2. Last 3 years data for ...
  • v-joesh-msft's avatar
    6 years ago

    Hi Anonymous ,

    Based on my research, I think you should create a new unconnected table and create the following measure as below:

    1. You need a separate date table for the slicer to choose year- quarter(do not create any relationship with other tables);

    2. Create a measure like the following:

    Measure =
    IF (
        ISFILTERED ( 'Dim selected table'[YQ] ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                'Date',
                AND (
                    'Date'[Year]
                        = SELECTEDVALUE ( 'Dim selected table'[Year] ) - 1
                        || 'Date'[Year]
                            = SELECTEDVALUE ( 'Dim selected table'[Year] ) - 2
                        || 'Date'[Year] = SELECTEDVALUE ( 'Dim selected table'[Year] ),
                    'Date'[Quarter] = SELECTEDVALUE ( 'Dim selected table'[Quarter] )
                )
            )
        ),
        CALCULATE ( SUM ( 'Table'[Value] ) )
    )

    Results are as follows:

     

     

    Here is a demo, please try it:

    https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ETGKc3g6UTFHl27NzE0aCrEBhOvPgwsCVHVQRmd5bKdOxQ?e=2lX5i8

     

    Best Regards,

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