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
v-deddai1-msft
5 years agoCommunity Support
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