Forum Discussion
DominicHill
2 years agoFrequent Visitor
Using a measure in DAX
Hi Folks, I have bamboozled myself - I can normally work out most things but this is evading me. This code works; PriceTable = ADDCOLUMNS( GENERATESERIES(1, 12, 1), "Row", [Value], "P...
OwenAuger
2 years agoSuper User
Hi DominicHill
- Can you clarify what the issue is 🙂 ? i.e. what result are you currently getting vs what you expect?
- In what context are you evaluating the PriceTable expression? Is it one part of a measure or something else?
- Regardless of the definition of [Origin Price], its value will not change in any part of the PriceTable expression. In other words, [Origin Price] will be effectively constant for the purpose of the PriceTable expression (unless you want some other behaviour).
- The table expression itself looks it should execute fine. I would just recommend simplifying to:
PriceTable =
VAR OrigPrice = [Origin Price]
VAR Ratio = 0.8
RETURN
ADDCOLUMNS (
GENERATESERIES ( 1, 12, 1 ),
"Row", [Value],
"Price", OrigPrice * POWER ( Ratio, [Value] - 1 )
)
Regards
DominicHill
2 years agoFrequent Visitor
Hi Owen,
Sorry I haven't responded before - I have been away.
The code from me generates
Which if I put into a matrix shows
The problem is that the first value (the 3,500) should be based on a calculated measure
This 'orig price' will change depending on other selections. Then Row 1 of the table should start at whatever is in the calculated measure 'Orig Price', and the remaining rows then calculate.
Does that make sense?