- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

# Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 09:07 PM

I have 2 Price Lists for 2015 and 2016.

2015 Price | 2016 Price | |||

Product | Price | Product | Price | |

Pen | 5 | Pen | 6 | |

Note | 10 | Note | 10 | |

Mouse | 100 | Keyboard | 150 |

I want to know the price difference for the products included in both 2015 and 2016.

Product | 2015 Price | 2016 Price | Price Up |

Pen | 5 | 6 | 1 |

Note | 10 | 10 | 0 |

Can anyone tell me how to solve this with Power BI?

So far, I've created a relationship between the 2 tables, and created a metric report.

But I don't know how to add a new column for Price Up, to calculate 2016 Price - 2015 Price.

Product | 2015 Price | 2016 Price |

Pen | 5 | 6 |

Note | 10 | 10 |

Solved! Go to Solution.

Accepted Solutions

## Re: Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 10:26 PM

Hi @Jinji

Go to Edit Queries

Click on the table in which you want to add new column.

Click on "Add column" on Tool bar

Add custom column with name 'Price UP' and write the logic as (2016 Price - 2015 Price)

Go to File > Apply & Close

Thus your changes are saved.

## Re: Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 10:58 PM

@Jinji - had a quick play with it as the totals werent adding up. You can do a merge of the tables using a full outer join through query editor. Then add this conditional column

Then I renamed some columns and deleted some and added a custom column:

This then calculates the total difference properl

All Replies

## Re: Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 10:26 PM

Hi @Jinji

Go to Edit Queries

Click on the table in which you want to add new column.

Click on "Add column" on Tool bar

Add custom column with name 'Price UP' and write the logic as (2016 Price - 2015 Price)

Go to File > Apply & Close

Thus your changes are saved.

## Re: Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 10:29 PM

@Jinji - In this situation you could just use a measure to work out the difference.

First I created two measures:

Price total 2016 = SUM('Price 2016'[Price])

Price total 2015 = SUM('Price 2015'[Price])

Then I created this measure:

Price differnce 2015-16 = IF(OR(ISBLANK('Price 2015'[Price total 2015]),ISBLANK('Price 2016'[Price total 2016])),BLANK(),'Price 2016'[Price total 2016]-'Price 2015'[Price total 2015])

This last measure removes the items where there may have been no price in 2015 or 2016.

Let me know if this works.

Giles

## Re: Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 10:58 PM

@Jinji - had a quick play with it as the totals werent adding up. You can do a merge of the tables using a full outer join through query editor. Then add this conditional column

Then I renamed some columns and deleted some and added a custom column:

This then calculates the total difference properl

## Re: Calculate with multiple tables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2016 11:21 PM

Hey Jinji,

1. Create new measure from DAX

Different 2015-2016 =

**if( isblank(sum('2015'[Price])) || sum('2015'[Price]) = 0,**

**Sum('2016'[Price]),**

**Sum('2016'[Price])-Sum('2015'[Price]))**

2. From Power Query

In Query Editor window Merge these two Tables,

Then Add new column . there u can do the Calculation eg.(2016[price) - 2015(Price))

Before that please replace the "**NULL**" with **0 .** ** ** in Price field.

Let check it .....