# Power BI Exchange

View Only

## Difference of two columns in a matrix

• #### 1.  Difference of two columns in a matrix

Posted Dec 06, 2022 06:38 AM
Edited by Klaus T Dec 06, 2022 06:39 AM
Hi

This is my table in PBI:
 Date Custormer Product Type value 06-12-2022 Alpha 1A X 500 06-12-2022 Alpha 1A Y 600 06-12-2022 Beta 1A X 1000 06-12-2022 Beta 1A Y 1800

And I want result in a matrix
 Matrix Alpha X Y Difference 1A 500 600 100 Beta 1A 1000 1800 800 Filter on date

How can I make a measure that can calculate the difference?

------------------------------
Klaus T
------------------------------

• #### 2.  RE: Difference of two columns in a matrix

Posted Dec 06, 2022 07:47 AM

Hi Klaus,

If the type is limited to X & Y, then create a calculate formula with a filter of x or y.

e.g.

x = Calculate (sum(value),Type = "X")

y = Calculate (sum(value),Type = "y")

To calculate the difference, create a measure Diff = x-y

I assume that your data is as simple as you presented but if your data is much complicated, please explain further including the limitations that you are facing.

Regards,
Rd

------------------------------
Senior Finance Analyst
------------------------------

• #### 3.  RE: Difference of two columns in a matrix

Posted Dec 06, 2022 08:17 PM

Olá

Fiz no Power Query.

Veja se o anexo ajuda.

------------------------------
Vilmar Santos
------------------------------

Attachment(s)

Teste1.pbix   73 KB 1 version

• #### 4.  RE: Difference of two columns in a matrix

Posted Dec 07, 2022 04:16 AM
Edited by Klaus T Dec 07, 2022 05:54 AM
Hi Vilmar

The source is like this table:
 Date Customer Product Type USD 06-12-2022 Alpha 1A X 500 06-12-2022 Alpha 1A Y 600 06-12-2022 Beta 1A X 1000 06-12-2022 Beta 1A Y 1800

In your test it is a little bit different, so it is not a solution. Sorry.

------------------------------
Klaus T

------------------------------

• #### 5.  RE: Difference of two columns in a matrix Best Answer

Posted Dec 07, 2022 05:07 AM
Hi Klauz,

Use the attached then.

Rd

------------------------------
Senior Finance Analyst
------------------------------

Attachment(s)

Test_.pbix   39 KB 1 version

• #### 6.  RE: Difference of two columns in a matrix

Posted Dec 07, 2022 05:52 AM
Edited by Klaus T Dec 07, 2022 05:54 AM
Yes  - Of course - Thank you.

------------------------------
Klaus T------------------------------