Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not 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 column to get the above conditions?

 

Product typeRevenueT PriceM PriceMargin
A4036 40-36
A5450 54-50
B32282732-27
B43403843-38
A3330 33-30
B29272529-25
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@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] )
)

 

 

smpa01_0-1640826010994.png

 

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_1-1640826326317.png

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

Did these suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Jihwan_Kim
Super User
Super User

Hi,

The below is one of ways to create a calculated column.

 

Picture1.png

 

Margin CC =
IF(
Data[Product type] = "A" , Data[Revenue] - Data[T Price] ,
IF ( Data[Product type] = "B" , Data[Revenue] - Data[M Price] ,
BLANK()
)
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


smpa01
Super User
Super User

@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] )
)

 

 

smpa01_0-1640826010994.png

 

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_1-1640826326317.png

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors