Are there other DAX functions that are computed not exactly as recorded?

anvg

Active Member
Joined
Feb 14, 2012
Messages
485
My question grows from frognz's topic "Returning last date and date before the last". I know about CALCULATE function which "wraps" a filter argument in it
For example
=CALCULATE(SUM('sales', 'sales'[Qty]<36)
is really calculated as
=CALCULATE(SUM('sales', FILTER(ALL('sales'[Qty]),'sales'[Qty]<36))
If I understood Matt Allington's answer on that topic problem right it is happend because FILTER function wraps the LastSaleDate measure into CALCULATE function
Instead
CALCULATE(MAX('sales'[TranDate]),FILTER('sales', 'sales'[TranDate]<[LastSaleDate))
is really calculated
CALCULATE(MAX('sales'[TranDate]),
FILTER('sales', 'sales'[TranDate]< CALCULATE([LastSaleDate]))
)<calculate([lastsaledate])))<calculate(lastsaledate)))
<calculate(<strong><calculate([lastsaledate])))[ code]

Are there other DAX functions that are computed not exactly as recorded (they have background wrap)?

Regards,</calculate([lastsaledate])))[></calculate(<strong></calculate([lastsaledate])))<calculate(lastsaledate)))
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi anvg,
this is called the "Calculate Wall" and is supposed to hurt everytime you hit it :-)

I used to see it as the nastiest shortcut ever invented, but finally came to terms with it, using this mantra: "Without Calculate there would be nothing."

Which actually translates into: Without this (through and through mean) implicit Calculate-function that is wrapped around each measure - there wouldn't be measures at all - that could be placed inside the measure-section of your pivot table.

Which - if you read it the other way around - leads to Alberto's sentence: "... that whenever a MEASURE is used inside a formula, it is automatically surrounded by a hidden CALCULATE.": Because there it reveals it's true face.

Head up and stay queryious :-)
 
Upvote 0
<calculate([lastsaledate])))<calculate(lastsaledate)))
<calculate(<strong><calculate([lastsaledate])))[ code]

Are there other DAX functions that are computed not exactly as recorded (they have background wrap)?

indeed.

Relatedtable has an implicit calculate
lastdate has an implicit CALCULATETABLE

There may be more. But the difference with these is you "expect" this behaviour because they do a specific task. It is the hidden CALCULATE inside the hand written measures that are trickiest to get your head around.
</calculate([lastsaledate])))[></calculate(<strong>
</calculate([lastsaledate])))<calculate(lastsaledate)))
 
Upvote 0
Thank ImkeF very much. You are always helping out and represent cognitive links.
Thank Matt, your explanation is important for my understanding of DAX engine.

Simplified I can say
Each function which has a column or a table as argument is implicity surrounded CALCULATE function with a filter which DAX engine defines by current computed content. It defines a calculate wall problem.
When I use MAX(Sales[TranDate]) directly in Penultimate1 measure that is precalculated and placed into FILTER as a constant.
But if I use LastSaleDate measure than it is placed into FILTER as a function reference and in result LastSaleDate works in row content.
It has some logic for me. Am I right?
 
Upvote 0
Yes, but With a slight clarifications.

each "measure" (not function) is wrapped in an implicate CALCULATE regardless of they types of arguments contained within.

I'm not really sure what you mean about the second point.

Finally, If LastSaleDate is a measure and it is used inside FILTER (or any other measure with a row context), the row context is converted to a filter context for each iteration of the row context in FILTER. The point is not that it is working in a row context because everything inside the FILTER is working in a row context. It is the conversion of the row context to a filter context at is important.
 
Upvote 0
Thank a lot Matt for your answer.
I thought that my some knowledge about SQL and programming and information on existing blogs and forums would be enough for understanding Power Pivot. I was mistaken. I am not ready to open discussion about using a measure in FILTER function. I will buy "The definitive guide to DAX" and will read it and maybe after we will carry on.
Regards,
 
Upvote 0

Forum statistics

Threads
1,224,157
Messages
6,176,744
Members
452,741
Latest member
Muhammad Nasir Mahmood

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top