Forum Discussion

alexoriginal's avatar
alexoriginal
Frequent Visitor
7 years ago

Add two columns in matrix together

Hi

Just started using Power BI

Need to know how can I get the % change for the two corresponding months eg , Jan 2017  to  January 2018  ( please see image)

 

Thank you

2 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi alexoriginal,

     

    Can you share a dummy sample file? I'm afraid we can't add it directly. But maybe we can leverage the Total field like below.

    Measure 10 =
    IF (
        HASONEVALUE ( DimDate[YearMonth] ),
        SUM ( FactSales[SalesQuantity] ),
        DIVIDE (
            CALCULATE (
                SUM ( FactSales[SalesQuantity] ),
                FILTER ( ALL ( DimDate ), DimDate[YearMonth] = MIN ( DimDate[YearMonth] ) )
            ),
            CALCULATE (
                SUM ( FactSales[SalesQuantity] ),
                FILTER ( ALL ( DimDate ), DimDate[YearMonth] = MAX ( DimDate[YearMonth] ) )
            )
        )
    )
    

    Add_two_columns_in_matrix_together

     

    Best Regards,

    Dale

  • Hi,

     

    Create a calendar Table and write the following calculated column formulas to extract Year and Month

     

    Year=YEAR(Calendar[Date])

    Month=FORMAT(Calendar[Date],"mmmm")

     

    Create a relationship from Date column of your base data table to the Date column of your Calendar Table.  In your visual, drag Year and Month from the Calendar Table.  Write these measures

     

    Values=SUM(Data[Value])

    Values in same period last year=CALCULATE([Values],SAMEPERIODLASTYEAR(Calendar[Date]))

    Growth in value over same period last year=[Values]/[Values in same period last year]

     

    Hope this helps.