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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
migueldfr
Helper IV
Helper IV

Building a Matrix with Asymmetrical Columns and Rows in Power BI

Hello folks,

 

I am sttrugling with this sheet in this small concept

 

I would like to create a pivot table and a bar chart upper which describe the table.

 

Pivot table should contains the values of each quarter in each row and the values for each year in each column. Attached screenshot: 

 

migueldfr_0-1728585288620.png

QuarterYearTotal Importe Encargo
Q120221593980
Q12023196626146
Q12024176830989
Q22022159388242
Q22023201556431
Q2202417388848
Q3202217491518
Q32023228064979
Q32024178882189
Q42022166886332
Q42023193844812
Q4202418604966

 

 

I would like to add two more columns into the table in power bi. Which will show up the diference between year(today) - year(today) -1 for each quarter and anothe column with the difference in % (variance

 

This is the plot that I created in first instance.

 

migueldfr_1-1728585530508.png



Thank you so much 

I would appreaciatte any help.

 

 

6 REPLIES 6
Anonymous
Not applicable

Hi @migueldfr ,

Thanks for ToddChitt's reply!

And @migueldfr , 

Which will show up the diference between year(today) - year(today) -1 for each quarter and anothe column with the difference in % (variance) 

Are you trying to calculate the difference between two adjacent years in the same quarter?

If yes, please try to use these two DAXs to create calculated columns:

difference = 
VAR _Year = [Year]
VAR _Quarter = [Quarter]
VAR _Current = 
CALCULATE(
    SUM('Table'[Total Importe Encargo]),
    ALL('Table'),
    'Table'[Year] = _Year && 'Table'[Quarter] = _Quarter
)
VAR _Previous = 
CALCULATE(
    SUM('Table'[Total Importe Encargo]),
    ALL('Table'),
    'Table'[Year] = _Year - 1 && 'Table'[Quarter] = _Quarter
)
VAR _MINYear = 
CALCULATE(
    MIN('Table'[Year]),
    ALL('Table')
)
RETURN
IF(
    'Table'[Year] = _MINYear,
    0,
    _Current - _Previous
)
variance = 
VAR _Year = [Year]
VAR _Quarter = [Quarter]
VAR _Currentdifference = [difference]
VAR _Previous = 
CALCULATE(
    SUM('Table'[Total Importe Encargo]),
    ALL('Table'),
    'Table'[Year] = _Year - 1 && 'Table'[Quarter] = _Quarter
)
VAR _MINYear = 
CALCULATE(
    MIN('Table'[Year]),
    ALL('Table')
)
RETURN
IF(
    'Table'[Year] = _MINYear,
    0,
    _Currentdifference / _Previous
)

And the final output is as below:

vjunyantmsft_0-1728614957356.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Good afternoon everyone.

Following the last example I am doing some new features and seem like I am getting there, but sadly I left something.

I have created a matrix with the Quarter and Years

Also I added a Total of sales, Difference between Quarters (from each year) and Variance (%) 

As a final result, I would like to create a Matrix with Year on the top and Quarter on the Left side...

migueldfr_0-1728755879395.png

 

At the moment, I have this:

migueldfr_1-1728755918199.png

 

 

Thank you for any help you could bring to me

I would appreaciate



Hello @Anonymous 

thank you for you response. 

I guess we are close to the result.
I would like to replicate this table made in excel.

migueldfr_0-1728629644375.png

The point here, is depend on what you are using, if you using if you use pivot table you are gonna see it like this:
ROWS = QUARTER

COLUMNS = YEAR

 

migueldfr_1-1728629737772.png

QUARTER202220232024DiferenciaVarianza
Q11593980196626146176830989  
Q215938824217491518166886332  
Q3201556431228064979193844812  
Q41738884817888218918604966  

I would appreciate your help 

Thank you in advance



I keep working and I found another way to approah.

Building a Matrix with Asymmetrical Columns and Rows in Power BI

migueldfr_0-1729028804635.pngmigueldfr_1-1729028820019.png


This what I am using.
I created a table to do it and aslo a measure.

migueldfr_2-1729028856915.png

 

Valores_A_mostrar = 
    VAR Anioseleccionado = VALUE(SELECTEDVALUE(x_Encabezados_tabla[Orden]))  -- Aseguramos que Anioseleccionado es un valor numérico
    VAR AnioActual = YEAR(TODAY())
    VAR ValorAnioActual = CALCULATE([Total Importe Encargo], FILTER('MasterCalendar', 'MasterCalendar'[Year] = AnioActual))
    VAR ValorAnioAnterior = CALCULATE([Total Importe Encargo], FILTER('MasterCalendar', 'MasterCalendar'[Year] = AnioActual - 1))

    VAR Diferencia = ValorAnioActual - ValorAnioAnterior
    VAR PorcentajeCambio = DIVIDE(Diferencia, ValorAnioAnterior, 0)

    RETURN 
        SWITCH(
            TRUE(),
            Anioseleccionado < 5, [Total Importe Encargo], -- Para los valores menores a 5, muestra el Total Importe Encargo
            Anioseleccionado = 5, Diferencia,  -- Cuando el valor de Orden es 5, muestra la diferencia
            Anioseleccionado = 6, FORMAT(PorcentajeCambio, "0.00%") -- Cuando el valor de Orden es 6, muestra el porcentaje
            
        )

 

But sadly, this does not work as I expected.

Could anyone give me a hand with this ?

Thanks

ToddChitt
Super User
Super User

Check out Visual Calculations

Using visual calculations in Power BI Desktop - Power BI | Microsoft Learn

Create a new Visual Calculation using the PREVIOUS function, and use AXIS of COLUMNS. Once you have that, you could probably figure out the Variance and Delta Visual Calculations as well.




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Hello, 

I am not able to select the one you are talkig about 

migueldfr_0-1728592002595.png

 

Even I tried to add in the preview preliminary but nothing comes out.

 

Thank you

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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