Forum Discussion
Understanding the DAX Measure
- 6 years ago
Good to see you are digging in to understand DAX with a simple example first. One comment. You used "measure" to describe what you put in a calculated column. While both Measures and Calculated Columns contain DAX expressions, they are not interchangeable. For example, the first variable in your expression (=Table1[Value1]) would return an error in a Measure. Calculated Columns have row context so it knows to get the value on that row (a measure would expect that column to be aggregated somehow).
I would encourage you to learn to write measures wherever possible, and only do Calculated Columns when you need something for the axis/category/legend of a visual, or for performance reasons.
In any case, the FILTER() function will return only rows that return TRUE(). In your case, there are three conditions. To pass all three, the iterated row (in FILTER()) has to
1 - be a different row than the current one (ID <> index)
2 - Value1 has to be less than the stored Value1
and
3 - Value2 has to be greater than the stored Value2
For the 1st row, there are no rows with Value1 <6, so you get blank
For the 2nd row, only ID 10 row meets all 3, so you get a result of 1.
For the 3rd row, only the 2nd row meets all 3, so you get a result of 1
For the 4th row, there are no rows with Value2 >21, so you get blank (not sure why you show 0 there)
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
Anonymous - Think of EARLIER as "current". So basically, the current value of something within the current context. Here is a good blog article about using EARLIER: See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586
- Anonymous6 years agoNot applicable
Greg_Deckler I have read that post and I am also calculation MTTR, MTBF but my data is not the same as yours. I have to filter differents dates overlapping and some other stuff. that's why I am taking small example to understand the iteration with earlier function.
can you explain me all iteration for any one ID of my dataset so that I can understand what's happening.
thanks for looking into my problem.