Luan Vieira
Luan Vieira

Reputation: 117

Measure not filtering lastdate

I can't get Power BI to filter by last date in file.

When I try:

test = CALCULATE(
    DISTINCT(table[Date]),
    filter(
        all(table[Date]),
        table[Date] =  date(2019,3,1)
    )
)

It returns me the date March 1, 2019.

But if I use

test = CALCULATE(
    DISTINCT(tabela_ajustada[Data]),
    filter(
        all(tabela_ajustada[Data]),
        tabela_ajustada[Data] =  LASTDATE(tabela_ajustada[Data])
    )
)

It won't work, it's not filtering at all, so I get an error because it returns multiple values and I can't add to the card.

table[Date] has multiple non unique values.

Upvotes: 0

Views: 105

Answers (1)

Olly
Olly

Reputation: 7891

Change to:

test = 
CALCULATE(
    DISTINCT(tabela_ajustada[Data]),
    FILTER(
        ALL(tabela_ajustada[Data]),
        tabela_ajustada[Data] =  LASTDATE ( ALL ( tabela_ajustada[Data] ) )
    )
)

Upvotes: 1

Related Questions