Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.5 kB
2
Indexable
Never
Anterior = 
VAR vDEST1 = MAX('Campos COSTES'[DEST1])
VAR vDEST2 = MAX('Campos COSTES'[DEST2])
VAR vDEST3 = MAX('Campos COSTES'[DEST3])
VAR vDEST4 = MAX('Campos COSTES'[DEST4])
VAR vDEST5 = SELECTEDVALUE('Campos COSTES'[DEST5])
VAR vAmount = SWITCH(TRUE(),
            vDEST1 = "REVENUES", SWITCH(TRUE(),
                                            ISINSCOPE('Campos COSTES'[DEST5]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[EDC]=vDEST5),
                                            ISINSCOPE('Campos COSTES'[DEST4]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 4]=vDEST4),
                                            ISINSCOPE('Campos COSTES'[DEST3]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 3]=vDEST3),
                                            ISINSCOPE('Campos COSTES'[DEST2]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 2]=vDEST2),
                                            ISINSCOPE('Campos COSTES'[DEST1]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 1]=vDEST1)),
            vDEST1 = "EXPENSES", SWITCH(TRUE(),
                                            ISINSCOPE('Campos COSTES'[DEST5]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[EDC]=vDEST5),
                                            ISINSCOPE('Campos COSTES'[DEST4]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 4]=vDEST4),
                                            ISINSCOPE('Campos COSTES'[DEST3]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 3]=vDEST3),
                                            ISINSCOPE('Campos COSTES'[DEST2]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 2]=vDEST2),
                                            ISINSCOPE('Campos COSTES'[DEST1]), CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 1]=vDEST1)), 
            vDEST1 = "OP. RESULT", CALCULATE(SUM(Costes[COSTE_TOTAL]),'Costes'[Conversion.Dest. 1] = "REVENUES") - CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 1] = "EXPENSES"),
            vDEST1 = "Transfer Margin", 0.05*CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 1] = "REVENUES", Costes[Conversion.Dest. 2] = "CLIENTS"),
            vDEST1 = "OP. PROFIT", CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 1] = "REVENUES") - CALCULATE(SUM(Costes[COSTE_TOTAL]), Costes[Conversion.Dest. 1] = "EXPENSES") - 0.05*CALCULATE(SUM(Costes[COSTE_TOTAL]),Costes[Conversion.Dest. 1] = "REVENUES", Costes[Conversion.Dest. 2] = "CLIENTS"))

RETURN vAmount