Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

How to add Variance Column to Matrix

Hello, I am pretty new to PowerBI and  I am trying to add a few columns to the below matrix that would calculate the difference between each reporting pariod:     In other words, I need 3 m...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    You can create the measures as below to replace the original measures [Acct],[Balance] and [WAR]:

    Acct Variance =
    VAR _2022 =
        SUMX ( FILTER ( 'Table', 'Table'[ProdDt] = DATE ( 2022, 12, 31 ) ), [Acct] )
    VAR _2023 =
        SUMX ( FILTER ( 'Table', 'Table'[ProdDt] = DATE ( 2023, 1, 31 ) ), [Acct] )
    RETURN
        IF ( ISINSCOPE ( 'Table'[ProdDt] ), [Acct], _2023 - _2022 )
    Balance Variance =
    VAR _2022 =
        SUMX ( FILTER ( 'Table', 'Table'[ProdDt] = DATE ( 2022, 12, 31 ) ), [Balance] )
    VAR _2023 =
        SUMX ( FILTER ( 'Table', 'Table'[ProdDt] = DATE ( 2023, 1, 31 ) ), [Balance] )
    RETURN
        IF ( ISINSCOPE ( 'Table'[ProdDt] ), [Balance], _2023 - _2022 )
    WAR Variance =
    VAR _2022 =
        SUMX ( FILTER ( 'Table', 'Table'[ProdDt] = DATE ( 2022, 12, 31 ) ), [WAR] )
    VAR _2023 =
        SUMX ( FILTER ( 'Table', 'Table'[ProdDt] = DATE ( 2023, 1, 31 ) ), [WAR] )
    RETURN
        IF ( ISINSCOPE ( 'Table'[ProdDt] ), [WAR], _2023 - _2022 )

    If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format, your visual Fields settings and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

    And 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