Context transition in measures

Anything related to PowerPivot and DAX Formuale
matthew
Posts: 14
Joined: Sun Apr 17, 2016 5:01 pm

Re: Context transition in measures

Postby matthew » Wed Jan 17, 2018 2:13 pm

A couple more comments if i may:

@Marc1988 wrote:
The result is still the same of bikes as had i just written this: Calculate ( [SalesBikes]; ProductName="Seat"). I actually expected to turn around the evaluation order because i applied context transition but I didnt get what i hoped for. However, it looks like Calculate evaluated it another context though.


Your issue here is that CALCULATE did evaluate things in a different context (sort of). What changed is you used SUMX over the entire 'Product' table. SUMX is an iterator so created a row context. But because you are iterating over the entire table, all the columns of 'Product' are transitioned into the Filter context - not just the Product[Name] column. So even though the inner CALCULATE overwrites the filter on 'Name', the rest of the columns still have their respective filters for the currently evaluated row and those filters are causing all but 'Bike' to return blank.

If you were to re-write the function like this:

ContextTransition :=
SUMX (
VALUES ( Product[Name] );
CALCULATE ( [SalesBikes]; Product[Name] = "Seat" )
)


you will get the results you had initially expected.

@P3Tom wrote:
but I do not think that context is occurring at all: SUM () is not an iterator like SUMX().


SUM( Table[Column] ) is just shorthand for SUMX( Table, Column ).

Hope this helps....

Marc1988
Posts: 7
Joined: Mon Jan 08, 2018 6:11 pm

Re: Context transition in measures

Postby Marc1988 » Wed Jan 17, 2018 5:30 pm

Hi Matthew

Thanks for your feedback.

Yes I think I misunderstood some things about evaluation context during context transition. I read the article by Jeffrey Wang once and it is very helpfull - though also tough to understand in some aspects.

Just to make sure I get it all right - would you mind making a code example (data doesnt matter) and go through each step you listed from Jeffreys article? Would be a great help.

Thanks in advance.

Marc

matthew
Posts: 14
Joined: Sun Apr 17, 2016 5:01 pm

Re: Context transition in measures

Postby matthew » Thu Jan 18, 2018 7:31 am

Marc1988, did you see my second post after post with link to Jeffrey Wang article?

If so, was it not clear?

Marc1988
Posts: 7
Joined: Mon Jan 08, 2018 6:11 pm

Re: Context transition in measures

Postby Marc1988 » Thu Jan 18, 2018 7:10 pm

Yes i did - its just confusing to take a code example and go through his steps one by one and explain exactly ehat happens. Do you mind? Else i can just try to study and read it again maybe.


Return to “PowerPivot/DAX”

Who is online

Users browsing this forum: No registered users and 1 guest

cron