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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Função DAX comparar linha a linha

Preciso fazer a seguinte tratativa, Se a moeda selecionada for "Real" Tenho que executar o código que multiplique o [ValorFOBTotalTM] pela'DW VW_CAMBIO'[Cotacao] daquele determinado

'DW VW_CAMBIO'[AnoMes], sendo que levando em consideração que a cotacao a ser trazida é apenas referente se a
'DW VW_CAMBIO'[IDMoeda] for igual a "2".

 

A tabela 'DW dimData[AnoMes] da base de dados não está relacionada ao 'DW VW_CAMBIO'[AnoMes] se eu relaciona-las manualmente através do Modelo pode ocorrer problemas.

 

Fiz um código mas ele está me retornando o seguinte erro: "Uma função 'PLACEHOLDER' foi utilizada em uma expressão True/False usada como expressão de filtro de tabela. Isso não é permitido."

 

Medida1 = 

IF (
    SELECTEDVALUE('DW dimMoeda'[DescMoeda]) == "Real",
        SUMX(
        'DW fatImportacaoCOMEX', 
        CALCULATE(MAX('DW fatImportacaoCOMEX'[ValorFOBTotalTM]),
        SWITCH(TRUE(),
        HASONEVALUE('DW VW_CAMBIO'[IDMoeda]), 
        SWITCH(TRUE(),
        SELECTEDVALUE('DW VW_CAMBIO'[IDMoeda]) == 2,
        1
    
   * MAX('DW VW_CAMBIO'[Cotacao])
        ),'DW fatImportacaoCOMEX'[SomaFOBTotal]
            )
        )
        )
)

 Quem puder me ajudar vou agradecer muito!

1 REPLY 1
v-rongtiep-msft
Community Support
Community Support

Hi @Anonymous ,

Please have a try.

Measure= VAR _A=MAX('DW fatImportacaoCOMEX'[ValorFOBTotalTM])*MAX('DW VM_CAMBIO'[Cotacao])
return
IF (max('DW dimMoeda'[DescMoeda]) ="Real",_a,If(  max('DW VW_CAMBIO'[IDMoeda]) = 2,1 * MAX('DW VW_CAMBIO'[Cotacao]),max('DW fatImportacaoCOMEX'[SomaFOBTotal]))

 

If I have misunderstood your meaning, Please provide more data and conditions according to the output you want.

 

How to Get Your Question Answered Quickly 

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors