Forum Discussion
piotr_gor
4 years agoHelper II
Get a text value from table in measure's variable
Hi there,
I've got a table with products, its type and price.
| Product Name | Type | Price |
| Product 1 | Shampoo | 5 |
| Product 2 | Soap | 2 |
| Product 3 | Gel | 3 |
| Product 4 | Shampoo | 4 |
| Product 5 | Body Butter | 6 |
| Product 6 | Body Butter | 7 |
Id' like to create a measure that reads every single Type value of each product and if that value is equel to "Shampoo" to multiply its price by 9%.
I wanted to create variables inside a measure to make more readable at least to me 😉
How do I retrieve product's type in variable?
So far I've got:
My measure =
VAR __Type= 'MyTable'[Type] -- this bit does not work
VAR __Price= SUMX( 'MyTable'[Price] )
VAR __Result = IF ( __Type= "Shampoo", __Price* 1.09, 0 )
RETURN
__Result
I wrote a post and something struck me. I should have created new column - not measure. It worked 🙂
2 Replies
- piotr_gorHelper II
I wrote a post and something struck me. I should have created new column - not measure. It worked 🙂