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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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