Forum Discussion
Calculate amount based on substring, show value on matching row (in a measure)
- 4 years ago
New Measure = SUMX( VALUES('Table'[Transaction Number]), VAR _current_tr_num = 'Table'[Transaction Number] VAR _correction = "C" & _current_tr_num VAR _result = CALCULATE([Amount Measure],'Table'[Transaction Number] = _correction) RETURN _result )
New Measure =
SUMX(
VALUES('Table'[Transaction Number]),
VAR _current_tr_num = 'Table'[Transaction Number]
VAR _correction = "C" & _current_tr_num
VAR _result = CALCULATE([Amount Measure],'Table'[Transaction Number] = _correction)
RETURN
_result
)
- Broderskap7774 years agoFrequent Visitor
Thank you both for the quick replies. Unfortunately, I can’t get any of the codes to work since I misread my own data. The numbers are not identical, but the first 0 is replaced with a "C" e.g.
For your code @SpartaBI , I tried to alter the code like this (for the second variable):
"C" & LEFT(_current_tr_num,LEN(_current_tr_num)-1) .. But I might be getting the logic wrong.
And for your code @tamerj1 I couldn’t get "selectedvalue" to work (it was greyed out and not found by intellicense) so I replaced it with "hasonevalue", but the code is returning blanks.
I apologize in advance if the solution is simple. but I am a beginner in DAX.- SpartaBI4 years ago
Community Champion
Broderskap777 replace the LEFT with RIGHT 🙂
- Broderskap7774 years agoFrequent Visitor
hahaha it's amazing how the brain can fail you at times :')
thank you, worked like a charm!