The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 type | Revenue | T Price | M Price | Margin |
A | 40 | 36 | 40-36 | |
A | 54 | 50 | 54-50 | |
B | 32 | 28 | 27 | 32-27 |
B | 43 | 40 | 38 | 43-38 |
A | 33 | 30 | 33-30 | |
B | 29 | 27 | 25 | 29-25 |
Solved! Go to Solution.
@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]
)
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
Hi,
The below is one of ways to create a calculated column.
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.
@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]
)
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
20 | |
18 | |
18 | |
14 | |
13 |
User | Count |
---|---|
38 | |
31 | |
22 | |
20 | |
18 |