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, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors