Forum Discussion

aaldo_666's avatar
aaldo_666
Icon for Helper I rankHelper I
4 years ago
Solved

Chart shows max one year back from slicer`s choice

How can I show 4 Quartals back data only on chart based on slicer. Other visuals should show what is selected in slicer. Goal: If I select 2020 Q1, then on chart I want to see 2021 Q1, Q2, Q3 and 20...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi aaldo_666 ,

    I created a sample pbix file(see attachment) for you, please check whether that is what you want. Assume that you have a year quarter dimension table as below, then you can create a measure as below:

    Measure = 
    VAR _selyear =
        SELECTEDVALUE ( 'YearQuarter'[Year] )
    VAR _selquarter =
        SELECTEDVALUE ( 'YearQuarter'[Quarter] )
    VAR _qnum =
        VALUE ( RIGHT ( _selquarter, 1 ) )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Sales amount] ),
            FILTER (
                'Table',
                IF (
                    _qnum = 4,
                    'Table'[Year] = _selyear
                        && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= 1
                        && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= 4,
                    (
                        'Table'[Year] = _selyear
                            && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= 1
                            && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= _qnum
                    )
                        || (
                            'Table'[Year] = _selyear - 1
                                && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= _qnum + 1
                                && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= 4
                        )
                )
            )
        )

    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. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards