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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Help with a conditional

Hello!

In my table I have three categories of product and quantities:

Category Quantity

Premium 50

Basic 30

Extra Costs 20

I need to create a new column "Quantity 2" To be able to multiply Quantity *2 only if it is Premium and if it is Basic or Extra Costs multiply it by 1.

1 ACCEPTED SOLUTION

It seems you are trying to create a measure not column. In that case you can use this code:-

Quantity2 =
IF (
    SELECTEDVALUE ( 'SaleProducts'[Product Category] ) = "Premium",
    SELECTEDVALUE ( 'SaleProducts'[Quantity] ) * 2,
    SELECTEDVALUE ( 'SaleProducts'[Quantity] ) * 1
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

7 REPLIES 7
Samarth_18
Community Champion
Community Champion

Hi @Syndicate_Admin ,

 

You can create a column as below:-

 

Quantity2 = if([category] = "Premium",[Quantity]*2,[Quantity]*1)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

I understand logic, but the category and Quantity columns are from my source table, they are not measured. so typing the dax function does not allow me to select the required columans

@Syndicate_Admin , You could try this:-

Quantity2 = if('Table'[category] = "Premium",'Table'[Quantity]*2,'Table'[Quantity]*1)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

it does not allow me to select the table, it only allows me to select measurements.

@Syndicate_Admin Whats the error your getting. Could you please share the code which you trying?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

My Table is called "SaleProducts", the column is "Product Category", when I try to write the function the table is not displayed:

Captura de pantalla 2022-08-23 143933.jpg

It seems you are trying to create a measure not column. In that case you can use this code:-

Quantity2 =
IF (
    SELECTEDVALUE ( 'SaleProducts'[Product Category] ) = "Premium",
    SELECTEDVALUE ( 'SaleProducts'[Quantity] ) * 2,
    SELECTEDVALUE ( 'SaleProducts'[Quantity] ) * 1
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.