Forum Discussion
Earlier function errors
- 6 years ago
Hi GunnerJ
As tested, when i use the "Earlier" function inside "Filter" function to produce a table, it would throw an error, the same as used in Top N function.
You could understand the "Earlier" meaning from this thread.
When using it in Topn or other formula which finally returns a table, it makes no sense in that case.
You could try the following workaround to get the expected result.
If you have any question, feel free to let me know.
Create measures
SUB = VAR previous = CALCULATE ( MIN ( Sheet7[nbr1] ), FILTER ( ALLSELECTED ( Sheet7 ), Sheet7[nbr2] = MAX ( Sheet7[nbr2] ) && Sheet7[cd] = "COMP" ) ) RETURN DATEDIFF ( previous, MAX ( Sheet7[tm] ), HOUR ) Or SUB 2 = VAR previous = CALCULATE ( MIN ( Sheet7[nbr1] ), FILTER ( ALLSELECTED ( Sheet7 ), Sheet7[nbr2] = MAX ( Sheet7[nbr2] ) && Sheet7[cd] = "COMP" ) ) VAR current1 = CALCULATE ( MAX ( Sheet7[tm] ), ALLSELECTED ( Sheet7 ) ) RETURN DATEDIFF ( previous, current1, HOUR )Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GunnerJ are you adding this as measure or column? it will not work in measure
Yes I was trying as a measure. I thought measures were used for multi row context and columns for single row context? I'm trying to compare one time to another so that's why I went with measure. When I switch to column I get the message "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value." I'm only trying to return one value but it will require a few columns to compute.