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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.