Forum Discussion

BartDekeyser's avatar
BartDekeyser
Frequent Visitor
3 years ago
Solved

Calendar, multiple dates but dates depend on each other

Goodmorning,   I am fairly new to Powerbi but loving it for the moment.    I have the following problem :  My data  : Year PubYear Category Value. 2009  2015      x             100 2009   201...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi BartDekeyser ,

    I created a sample pbix file(see the attachment), please check if that is what you want.

     

    Year by year% = 
    VAR _selcat =
        SELECTEDVALUE ( 'Table'[Category] )
    VAR _selyear =
        SELECTEDVALUE ( 'Table'[Year] )
    VAR _selpubyear =
        SELECTEDVALUE ( 'Table'[PubYear] )
    VAR _prepubyear =
        CALCULATE (
            MAX ( 'Table'[PubYear] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Category] = _selcat
                    && 'Table'[Year] = _selyear
                    && 'Table'[PubYear] < _selpubyear
            )
        )
    VAR _prepyvalue =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Category] = _selcat
                    && 'Table'[Year] = _selyear
                    && 'Table'[PubYear] = _prepubyear
            )
        )
    RETURN
        IF (
            ISBLANK ( _prepyvalue ),
            BLANK (),
            DIVIDE ( SUM ( 'Table'[Value] ) - _prepyvalue, _prepyvalue )
        )

     

    In addition, you can refer the following videos to get it.

    Power BI Year-Over-Year Growth % Calculations [DAX] - YouTube

    Power BI YEAR over YEAR (YoY) Change Calculations [DAX]

    If the above one can't help you, could you please explain your expected result base on your shared sample data?Thank you.

    Best Regards