Forum Discussion

lulcasl's avatar
lulcasl
Frequent Visitor
5 years ago
Solved

Measure resulting on wrong value within the context

There are two rolling measures I'm trying to achieve but both of them are NOT working as I think they should. There are no blank/empty/null values (pbix attached in the end) and yet it still doesn't...
  • jameszhang0805's avatar
    5 years ago

    lulcasl  Please correct your measure to :

    Contagem Placas AC = 
    SWITCH(
        MAX(f_MovMad[Turno]),
        "Turno 1", CALCULATE( DISTINCTCOUNT(f_MovMad[Placa do Cavalo]), f_MovMad[Turno]="Turno 1" ),
        "Turno 2", CALCULATE( DISTINCTCOUNT(f_MovMad[Placa do Cavalo]), f_MovMad[Turno]<>"Turno 3"),
        "Turno 3", CALCULATE( DISTINCTCOUNT(f_MovMad[Placa do Cavalo]), ALLSELECTED( f_MovMad[Turno]))
    )
    
    Viagens Realizadas ACC = 
    VAR _Max = MAX( 'f_MovMad'[Turno] ) 
    RETURN 
    CALCULATE( 
        [Viagens Realizadas],
            REMOVEFILTERS(),
            f_MovMad[Turno] <= _Max ,
            VALUES( 'd_CadTransportadoras'[Tipo de Transporte] ),
            VALUES( 'd_Calendário'[Data] )
        )

    And the selected column in your chart 

    Result: