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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
afrutos
Resolver I
Resolver I

SUMX IGNORE SOME ROWS

Hola, en mi PowerBi tengo una tabla de Facturas unida a la tabla calendario de 1 a * a través de fechafactura.

afrutos_0-1728654271181.png

Esta es la visual que necesito; actualmente estoy filtrando por el año actua, es decir 2024.
Estoy teniendo problemas para calcular la suma correcta de una medida.

La medida [NW FACT LY] es simplemente la suma de facturación.
la medida [AJUSTE LY...] es lo mismo pero ajustando el valor final de CL, ya que al total de CL para cada año tengo que sumar o restar un ajuste.

AJUSTE LY FACTURACIÓN FINAL =
VAR k = SELECTEDVALUE('Facturas Anexo'[TipoLiquidacion])
VAR YearTotal =
    CALCULATE(
        SUM('Facturas Anexo'[AJUSTE IMPORTE]),
        SAMEPERIODLASTYEAR('FACT_Dim_Calendar DAX'[Date])
    )

VAR adjustedValue =
    SWITCH(
        TRUE(),
        k = "CL" && SELECTEDVALUE('FACT_Dim_Calendar DAX'[#Año]) = 2018, YearTotal - 952721.8,
        k = "Op" && SELECTEDVALUE('FACT_Dim_Calendar DAX'[#Año]) = 2018, YearTotal - 622131.45,
        k = "CL" && SELECTEDVALUE('FACT_Dim_Calendar DAX'[#Año]) = 2021, YearTotal + 752152,
        k = "CL" && SELECTEDVALUE('FACT_Dim_Calendar DAX'[#Año]) = 2023, YearTotal - 1175870.95,
        k = "CL" && SELECTEDVALUE('FACT_Dim_Calendar DAX'[#Año]) = 2024, YearTotal - 885903.42,
        YearTotal
    )

RETURN
    IF(ISBLANK(adjustedValue), 0, adjustedValue)




Y lo que necesito en última instancia es sumar el valor correcto de los valores que arroja esa medida, pero me hace desaparecer la 2 y penultima línea.
SUMX LY AJUSTE FACTURACION =
SUMX(
    VALUES('Facturas Anexo'[TipoLiquidacion]),
    CALCULATE(

[AJUSTE LY FACTURACIÓN FINAL]

    )
)

Por favor, necesito ayuda, hay algo que no estoy entendiendo.

 

2 REPLIES 2
Anonymous
Not applicable

Hi @afrutos ,

 

Could you please provide some sample data or link to the pbix file?

 

 

Best regards,

Mengmeng Li

DataNinja777
Super User
Super User

Hi @afrutos ,

 

Although this does not directly address your requirement, hardcoding values directly into DAX measures is not good practice. It can lead to several problems, such as a lack of flexibility, high maintenance needs, increased error-proneness, and difficulty in auditing. A better approach would be to store those adjustment values in a separate lookup table and reference them dynamically. This makes your model easier to maintain, more scalable, less prone to errors, and easier to audit.

 

Best regards,

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.