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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.