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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.