Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
3 years ago
Solved

Subtract from two selected columns

Good afternoon

I would like to draw a graph in which the line obtained is the subtraction of two selected columns. Should you do it with DAX? Taking into account that you must change depending on the columns you select.

Thanks a lot.

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi cdoblare28 ,

    You can refer the following links to get it:

    Calculate Difference Between Two Columns in Power BI Matrix

    Matrix Visual: Subtracting two Columns

    2020 = SUMX(FILTER('Table','Table'[Year]=2020),'Table'[Value])
    
    2021 = SUMX(FILTER('Table','Table'[Year]=2021),'Table'[Value])
    
    Variance = [2021] - [2020]

    subtract two values in a graph

    Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
    
    diff = SUM(Sales[Sales Amount])- [Year behind Sales]

     

    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 Regard

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi cdoblare28 ,

    You can refer the following links to get it:

    Calculate Difference Between Two Columns in Power BI Matrix

    Matrix Visual: Subtracting two Columns

    2020 = SUMX(FILTER('Table','Table'[Year]=2020),'Table'[Value])
    
    2021 = SUMX(FILTER('Table','Table'[Year]=2021),'Table'[Value])
    
    Variance = [2021] - [2020]

    subtract two values in a graph

    Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
    
    diff = SUM(Sales[Sales Amount])- [Year behind Sales]

     

    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 Regard