Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi!
I'm trying to apply this to a column, but it's not returning the values i expected:
Seems like the [Data] =< EARLIER([Data]) filter is not working in this context of virtual table. Any tips on how to make it work?
Thanks in advance!
Solved! Go to Solution.
Hi @Anonymous
try this
Disponível =
VAR tp =
TOPN (
10,
FILTER (
Disponibilidade,
Disponibilidade[Descricao] = 'Previsão de Entrega'[Grupo]
&& Disponibilidade[Data] >= 'Previsão de Entrega'[Sequencia Corrigida]
),
Disponibilidade[Data], ASC
)
VAR temp =
ADDCOLUMNS (
tp,
"Soma",
VAR CurrentTPDate = [Date]
RETURN
SUMX ( FILTER ( tp, [Data] <= CurrentTPDate ), [Carga Disponível] )
)
RETURN
CALCULATE ( MINX ( temp, [data] ), FILTER ( temp, [Soma] > 0 ) )
Thank you @Anonymous
can you please explain what is the expected result?
Hi @Anonymous
you have nested iterators. I don't to which level of iteration you want to go back. But you can use EARLIEST to go back to the very first one. You can define inside EARLIER how many levels you need to go back. Alternatively you can store in a variable at the desired level.
I tried passing 2 as an argument of earlier, but it returns "EARLIER/EARLIEST refers to an earlier row context which doesn't exist."
I just wanted the sum of "Carga Disponível" where the date is equal or less than the one in the line context of the virtual table "tp"
@Anonymous
You cannot access the row context created by ADDCOLUMNS using EARLIER because you have CALCULATE which performs context transition. Therefore, you have to store it in variable outside CALCULATE
I hope this works with you
Disponível =
VAR tp =
TOPN (
10,
FILTER (
Disponibilidade,
Disponibilidade[Descricao] = 'Previsão de Entrega'[Grupo]
&& Disponibilidade[Data] >= 'Previsão de Entrega'[Sequencia Corrigida]
),
Disponibilidade[Data], ASC
)
VAR temp =
ADDCOLUMNS (
tp,
"Soma",
VAR CurrentTPDate = [Date]
RETURN
CALCULATE (
SUMX ( tp, [Carga Disponível] ),
FILTER ( tp, [Data] <= CurrentTPDate )
)
)
RETURN
CALCULATE ( MINX ( temp, [data] ), FILTER ( temp, [Soma] > 0 ) )
Tthanks for exlpaining the context issue!
But i tried your code and it still returns the same results, unfortunatelly
Here's how it looks on the test table
Hi @Anonymous
try this
Disponível =
VAR tp =
TOPN (
10,
FILTER (
Disponibilidade,
Disponibilidade[Descricao] = 'Previsão de Entrega'[Grupo]
&& Disponibilidade[Data] >= 'Previsão de Entrega'[Sequencia Corrigida]
),
Disponibilidade[Data], ASC
)
VAR temp =
ADDCOLUMNS (
tp,
"Soma",
VAR CurrentTPDate = [Date]
RETURN
SUMX ( FILTER ( tp, [Data] <= CurrentTPDate ), [Carga Disponível] )
)
RETURN
CALCULATE ( MINX ( temp, [data] ), FILTER ( temp, [Soma] > 0 ) )
That actually worked! Thank you!
User | Count |
---|---|
17 | |
14 | |
14 | |
13 | |
12 |
User | Count |
---|---|
19 | |
15 | |
15 | |
11 | |
10 |