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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Crissceron
Frequent Visitor

Matrix subtotal per column issue - Need help with a measure to show column subtotals in a matrix

I'm working on a Power BI matrix where I have two columns in the rows: [Date] from 'TablaCalendario' and [Turnos] from 'Tabla turnos'. In the columns of the matrix, I'm using the [Ingresos] column from 'Tipo de ingresos', which has six values: Perforacion, Horas cliente, Habilitación, Instalación sonda, Equipo bombeo, and Otros.

I've created a measure called "Ingresos Diarios" to calculate the values for the matrix, and it's showing the values correctly. However, the measure is not summing the values by column, only by row. So when I add a Total column, it shows blanks values instead of the correct sum of values.

 

You can see the next picture as example.

 

Crissceron_0-1684116406693.png


This is the code for the measure "Ingresos diarios" 

 

 

Ingresos Diarios = 
SWITCH (
    TRUE (),
    HASONEVALUE ('Tipo de ingresos'[Ingresos]),
        SWITCH (
            SELECTEDVALUE ('Tipo de ingresos'[Ingresos]),
            "Perforacion", SUMX ('Curva S', 'Curva S'[Ingreso por ventas]),
            "Horas cliente", SUMX ('Hrasfaenas', 'Hrasfaenas'[Ingreso por horas]),
            "Habilitación", 
                
                   SUMX ('LBRDR S42 habilitacion', 'LBRDR S42 habilitacion'[Ingreso por habilitacion real])+
                    SUMX ('LBRDR habilitacion horas', 'LBRDR habilitacion horas'[Ingreso habilitacion desarrollo + limpieza]),
            "Instalación sonda", SUMX ('LBRDR instalacion', 'LBRDR instalacion'[Ingreso por instalacion sonda]),
            BLANK()
        ),
    BLANK()
)

 

 



Can anyone help me create a measure that will show the row subtotals in the matrix correctly? Thanks in advance for your help!

 

 

1 ACCEPTED SOLUTION
Crissceron
Frequent Visitor

I found the solution 

Ingresos Diariosdos =
SWITCH (
    TRUE (),
    HASONEVALUE ('Tipo de ingresos'[Ingresos]),
        SWITCH (
            SELECTEDVALUE ('Tipo de ingresos'[Ingresos]),
            "Perforacion", SUMX ('Curva S', 'Curva S'[Ingreso por ventas]),
            "Horas cliente", SUMX ('Hrasfaenas', 'Hrasfaenas'[Ingreso por horas]),
            "Habilitación",
               
                SUMX ('LBRDR S42 habilitacion', 'LBRDR S42 habilitacion'[Ingreso por habilitacion real]) +
                SUMX ('LBRDR habilitacion horas', 'LBRDR habilitacion horas'[Ingreso habilitacion desarrollo + limpieza]),
            "Instalación sonda", SUMX ('LBRDR instalacion', 'LBRDR instalacion'[Ingreso por instalacion sonda]),
            //"Equipo bombeo", 0,  // Summing values for the "Equipo bombeo" category
            //"Otros", 0,  // Summing values for the "Otros" category
            BLANK()
        ),
    SUM('Curva S'[Ingreso por ventas])+SUM('Hrasfaenas'[Ingreso por horas])+SUM('LBRDR S42 habilitacion'[Ingreso por habilitacion real])+sum('LBRDR habilitacion horas'[Ingreso habilitacion desarrollo + limpieza])+SUM('LBRDR instalacion'[Ingreso por instalacion sonda])  // Summing values for the Total column
)


View solution in original post

3 REPLIES 3
Crissceron
Frequent Visitor

I found the solution 

Ingresos Diariosdos =
SWITCH (
    TRUE (),
    HASONEVALUE ('Tipo de ingresos'[Ingresos]),
        SWITCH (
            SELECTEDVALUE ('Tipo de ingresos'[Ingresos]),
            "Perforacion", SUMX ('Curva S', 'Curva S'[Ingreso por ventas]),
            "Horas cliente", SUMX ('Hrasfaenas', 'Hrasfaenas'[Ingreso por horas]),
            "Habilitación",
               
                SUMX ('LBRDR S42 habilitacion', 'LBRDR S42 habilitacion'[Ingreso por habilitacion real]) +
                SUMX ('LBRDR habilitacion horas', 'LBRDR habilitacion horas'[Ingreso habilitacion desarrollo + limpieza]),
            "Instalación sonda", SUMX ('LBRDR instalacion', 'LBRDR instalacion'[Ingreso por instalacion sonda]),
            //"Equipo bombeo", 0,  // Summing values for the "Equipo bombeo" category
            //"Otros", 0,  // Summing values for the "Otros" category
            BLANK()
        ),
    SUM('Curva S'[Ingreso por ventas])+SUM('Hrasfaenas'[Ingreso por horas])+SUM('LBRDR S42 habilitacion'[Ingreso por habilitacion real])+sum('LBRDR habilitacion horas'[Ingreso habilitacion desarrollo + limpieza])+SUM('LBRDR instalacion'[Ingreso por instalacion sonda])  // Summing values for the Total column
)


Crissceron
Frequent Visitor

It didn't work.. 

 

Crissceron_0-1684151810380.png

It was my fault to explain the problem, it is not the subtotal per row.. it is the subtotal per column where i have the problem, still giving me blanks values. 

amitchandak
Super User
Super User

@Crissceron , Try like

 

Ingresos Diarios =
Sumx(
values ('Tipo de ingresos'[Ingresos]),
SWITCH (
SELECTEDVALUE ('Tipo de ingresos'[Ingresos]),
"Perforacion", SUMX ('Curva S', 'Curva S'[Ingreso por ventas]),
"Horas cliente", SUMX ('Hrasfaenas', 'Hrasfaenas'[Ingreso por horas]),
"Habilitación",

SUMX ('LBRDR S42 habilitacion', 'LBRDR S42 habilitacion'[Ingreso por habilitacion real])+
SUMX ('LBRDR habilitacion horas', 'LBRDR habilitacion horas'[Ingreso habilitacion desarrollo + limpieza]),
"Instalación sonda", SUMX ('LBRDR instalacion', 'LBRDR instalacion'[Ingreso por instalacion sonda]),
BLANK()
)
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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