Forum Discussion
Anonymous
5 years agoNot applicable
Create a static variable based on an expression for a dax measure
Hi, I'm having difficulty figuring out how to create a static variable within a dax measure. With a normal programming language, i'm use to variables being static at instantiation. However, with...
- 5 years ago
Hi Anonymous ,
You can use lookupvalue:
table2 = ADDCOLUMNS ( CROSSJOIN ( VALUES ( 'Table'[Rank] ), VALUES ( 'Table'[Day Of Week] ) ), "sales", VAR a = LOOKUPVALUE ( 'Table'[Sales], 'Table'[Rank], 'Table'[Rank], 'Table'[Day Of Week], 'Table'[Day Of Week] ) RETURN IF ( ISBLANK ( a ), LOOKUPVALUE ( 'Table'[Sales], 'Table'[Rank], 'Table'[Rank] - 1, 'Table'[Day Of Week], 'Table'[Day Of Week] ), a ) )If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Anonymous
5 years agoNot applicable
Hi,
I just figured out a work around. Instead of using MAX, I used LOOKUPVALUE.
Max is definitely more performant but Lookupvalue returns a static lookup (I believe).
It's a bit slower but it's intuitive and easy for others to understand. 👍