Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Create a variance column in Power BI

Hello, 

 

I have this data in excel and it is quite easy for me to do the calculation. 

 

The caluclation in the first cell under the Variance header is =IF(A2=A1,D2-D1,"")

 

ProductYearQuarterSales VolumeVariance
Product 12015-16Q1100 
Product 12015-16Q212020
Product 12015-16Q390-30
Product 12015-16Q415060
Product 2 2015-16Q114 
Product 2 2015-16Q2173
Product 2 2015-16Q3236
Product 2 2015-16Q421-2
Product 32015-16Q1220 
Product 32015-16Q2130-90
Product 32015-16Q322797
Product 32015-16Q432093

 

Basically i am trying to find the variance between the values for the same Product based on the year and quarter.

 

My data in power BI is set up in the same format however i cannot find if you can reference the above cell or not.

 

Any help would be great. 

 

Thanks,

  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Anonymous ,

     

    Do the following steps to achive the solution.

     

    Create (add new column) Index Column from 0.

    Create (add new column) Index Column from 1.

    Merge Query with the same table, join the same table on Index 0 and Index 1 (see the attachement for reference).

    Name the Merge Query as Next.

    Expand columns Product and Sales Volumn.

    Add a Custom Column = if [Next.Product]=[Product] then [Sales Volume]-[Next.Sales Volume] else null

     

    This will give you the expected results, I have tested and it is working.

    Let me know if you need any help.

     

    Regards,

    Pavan Vanguri.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Do the following steps to achive the solution.

     

    Create (add new column) Index Column from 0.

    Create (add new column) Index Column from 1.

    Merge Query with the same table, join the same table on Index 0 and Index 1 (see the attachement for reference).

    Name the Merge Query as Next.

    Expand columns Product and Sales Volumn.

    Add a Custom Column = if [Next.Product]=[Product] then [Sales Volume]-[Next.Sales Volume] else null

     

    This will give you the expected results, I have tested and it is working.

    Let me know if you need any help.

     

    Regards,

    Pavan Vanguri.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Brilliant works perfectly!

       

      Thanks very much.