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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors