Code Pope
Code Pope

Reputation: 5459

Visualize data in Power Bi as Matrix

I have the following data:

enter image description here

With the matrix diagram I was able to visualize it like that:

enter image description here

But I want to visualize this data:

enter image description here

How can I get the two columns Diff and Diff%?

Upvotes: 1

Views: 195

Answers (1)

alejandro zuleta
alejandro zuleta

Reputation: 14108

I'd create four measures to get the visualization you need. A measure called 2010 Value will calculate the 2010 sum of values; 2011 Value measure will calculate the 2011 sum of values. Diff(2011-2010) calculates the difference between 2011 and 2011 values, and Diff % calculates the porcentual difference between 2011 and 2010.

Use these DAX expressions to create the measures.

2010 Value = CALCULATE ( SUM ( [Value] ), YEAR ( 'Table'[Date] ) = 2010 )

2011 Value = CALCULATE ( SUM ( [Value] ), YEAR ( 'Table'[Date] ) = 2011 )

Diff(2011-2010) = ABS ( [2011 Value] - [2010 Value] )

Diff % = [Diff(2011-2010)]/[2010 Value]

Now you can add every measure to the Values pane in Power BI and it should provide the visualization you expect.

enter image description here

Note this is a static solution so if you have years different to 2010 and 2011 you have to create it manually. If you require dinamically calculate differences and other measures from the last two years in your data you have to play around with some time functions.

Let me know if this helps.

Upvotes: 2

Related Questions