Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Do the following steps to achive the solution.

 

Create (add new column) Index Column from 0.

Community Question1.png

Create (add new column) Index Column from 1.

Community Question2.png

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

Community Question.png

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.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Do the following steps to achive the solution.

 

Create (add new column) Index Column from 0.

Community Question1.png

Create (add new column) Index Column from 1.

Community Question2.png

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

Community Question.png

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
Not applicable

Brilliant works perfectly!

 

Thanks very much.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.