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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors