Forum Discussion
Anonymous
4 years agoNot applicable
Add new Conditional Column
I have a table like below, 2 types of products. I want the last column Margin as calculated like: For A: It is Revenue - T Price & For B: It is Revenue - M Price. How do I set up the Margin colum...
- 4 years ago
Anonymous you can write a measure like this
Measure = SWITCH ( TRUE (), MAX ( 'Table 1'[Product type] ) = "A", SUM ( 'Table 1'[Revenue] ) - SUM ( 'Table 1'[T Price] ), MAX ( 'Table 1'[Product type] ) = "B", SUM ( 'Table 1'[Revenue] ) - SUM ( 'Table 1'[M Price] ) )or a calculated column
Column = SWITCH ( TRUE (), 'Table 1'[Product type] = "A",'Table 1'[Revenue]- 'Table 1'[T Price] , 'Table 1'[Product type] = "B", 'Table 1'[Revenue] - 'Table 1'[M Price] )
smpa01
4 years agoCommunity Champion
Anonymous you can write a measure like this
Measure =
SWITCH (
TRUE (),
MAX ( 'Table 1'[Product type] ) = "A", SUM ( 'Table 1'[Revenue] ) - SUM ( 'Table 1'[T Price] ),
MAX ( 'Table 1'[Product type] ) = "B", SUM ( 'Table 1'[Revenue] ) - SUM ( 'Table 1'[M Price] )
)
or a calculated column
Column = SWITCH (
TRUE (),
'Table 1'[Product type] = "A",'Table 1'[Revenue]- 'Table 1'[T Price] ,
'Table 1'[Product type] = "B", 'Table 1'[Revenue] - 'Table 1'[M Price]
)