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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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