cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper IV

## Variation instead total in Matrix

Hello Experts,

I have a table with monthly sales by Year/Month, like this

 product code description year Jan feb Mar Apr May jun Jul Aug Sep Oct Nov Dec M01 Product A 2019 10 12 22 32 12 10 56 23 60 65 90 98 M01 Product A 2020 8 15 16 18 25 54 24 65 89 120 100 125 M02 Product B 2019 3 13 25 21 17 87 98 34 54 26 43 55 M02 Product B 2020 15 32 54 56 76 54 56 43 22 90 18 130

Then, I need generate a new row below each product with the Variation 2020 minus 2019 for each month.

Something like this:

I tried using a matrix, but it only make a sum of the values for each month, Is possible change it to generate a row with variation 2020 minus 2019?..

1 ACCEPTED SOLUTION
Super User

@gomezc73 - Put together a more concrete example for you with your data. The quick measure basically discusses the concept of how to do it, how to use HASONEVALUE, ISINSCOPE, etc. to find out where you are in the hierarchy/matrix and then you can decide how to do your calculation accordingly. See attached PBIX beneath sig. Page 6, Table (6), Measure 6.

``````Measure 6 =
VAR __productcode = MAX([product code])
VAR __description = MAX([description])
VAR __year = MAX([year])
VAR __Month = MAX([Attribute])
VAR __2019 = SUMX(FILTER(ALL('Table (6)'),[product code]=__productcode && [description]=__description && [Attribute]=__Month && [year]=2019),[Value])
VAR __2020 = SUMX(FILTER(ALL('Table (6)'),[product code]=__productcode && [description]=__description && [Attribute]=__Month && [year]=2020),[Value])
RETURN
IF(ISINSCOPE([year]),SUM([Value]),__2020 - __2019)``````

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
3 REPLIES 3
Super User

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Helper IV

Thanks fot your help, It can help is very similar. but i am not an expert user.. Sorry!!. Is very complicated to modified the formula to generated the difference insted MIN/Max or AVE?

Super User

@gomezc73 - Put together a more concrete example for you with your data. The quick measure basically discusses the concept of how to do it, how to use HASONEVALUE, ISINSCOPE, etc. to find out where you are in the hierarchy/matrix and then you can decide how to do your calculation accordingly. See attached PBIX beneath sig. Page 6, Table (6), Measure 6.

``````Measure 6 =
VAR __productcode = MAX([product code])
VAR __description = MAX([description])
VAR __year = MAX([year])
VAR __Month = MAX([Attribute])
VAR __2019 = SUMX(FILTER(ALL('Table (6)'),[product code]=__productcode && [description]=__description && [Attribute]=__Month && [year]=2019),[Value])
VAR __2020 = SUMX(FILTER(ALL('Table (6)'),[product code]=__productcode && [description]=__description && [Attribute]=__Month && [year]=2020),[Value])
RETURN
IF(ISINSCOPE([year]),SUM([Value]),__2020 - __2019)``````

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors