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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lakshmi9228
Helper III
Helper III

how do I create a column taking columns from different tables using if condition

I have a quantity column from one table, 
a dimension column from other table which is grouped by 2 - Bus , other,


Need to create a new column if naming 
if quantity > 2, business
if quantity <=2 && group = bus , business
other

Please help me with the solution.
Thanks

1 ACCEPTED SOLUTION
edhans
Super User
Super User

I'm not completely clear on what you are asking.  See if this file does what you want

I created a calculated column that I think has the logic you are looking for.

 

Category = 
VAR TotalQuantity = CALCULATE(SUM('Fact Table'[Quantity]))
RETURN
IF(
    TotalQuantity > 2,
    "Business",
    IF(
        TotalQuantity <= 2 && RELATED('Dimension Table'[Group]) = "Business",
        "Business",
        "Other"
    )
)

If that isn't what you need, please provide some sample data - both tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

I'm not completely clear on what you are asking.  See if this file does what you want

I created a calculated column that I think has the logic you are looking for.

 

Category = 
VAR TotalQuantity = CALCULATE(SUM('Fact Table'[Quantity]))
RETURN
IF(
    TotalQuantity > 2,
    "Business",
    IF(
        TotalQuantity <= 2 && RELATED('Dimension Table'[Group]) = "Business",
        "Business",
        "Other"
    )
)

If that isn't what you need, please provide some sample data - both tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi edhans,

I was trying the same thing before - due to small syntax problem.
It was not working.

Got where the mistake is from.

Thank you 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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