Forum Discussion

Prarabdha_07's avatar
Prarabdha_07
Frequent Visitor
2 years ago
Solved

Power BI IF condition with Different table Columns

Hii,

I am connecting two Tables Customer (StoreID) and Store(BusinessEntityID) --

 

 

 

I need to create a IF Measure using Columns from both the Tables like this --

Columns from Different Tables (IF) =
IF(SELECTEDVALUE(Store[Name]) = "A Bike Store" && SELECTEDVALUE(Customer[StoreID]) = 934,"Working","Not Working")

but while using this in a Table visual , values are duplicating and the attributes are not filtering as expected

Before --

 

 

 

After Adding that Measure --

 

 

 

How to resolve this?

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Prarabdha_07 

     

    After my testing, you can put the BusinessEntityID field in place of the StoreID field in the visualization if you wish.

     

    Best Regards,
    Yulia Xu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

16 Replies

  • What do you like to resolve?  The outcome matches your request exactly.

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        Do you want to suppress blank stores and "Not Working"  rows where a "Working"  row also exists?

  • Uzi2019's avatar
    Uzi2019
    Icon for Community Champion rankCommunity Champion

    Hi Prarabdha_07 

    As per your measure if the condition is satisfied then working is displaying where condition is not satisfying showing Not working. 

     

    Can you share the expected output by typing into excel like Input and output also?

    or share the screenshot of your expected output. would be better for us to quickly solve your problem.

     

     

    • Prarabdha_07's avatar
      Prarabdha_07
      Frequent Visitor

      this is expected --

      Measure is actually duplicating the values

  • Johnjose's avatar
    Johnjose
    Frequent Visitor

    hey, try to use switch function. Might you'll get correct answer.

  • rkottap's avatar
    rkottap
    Frequent Visitor

    Hi,
    Try below.

    Columns from Different Tables (IF) =
    VAR SelectedStoreName = SELECTEDVALUE ( Store[Name] )
    VAR SelectedStoreID = SELECTEDVALUE ( Customer[StoreID] )

    RETURN
    IF (SelectedStoreName = "A Bike Store" && SelectedStoreID = 934, "Working", "Not Working")

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Prarabdha_07 

     

    The following steps are for your reference:

     

    sample:

     

     

    Merge two tables in Power Query

     

    Expand the table

     

    Close & Apply

     

    Create a measure as follows:

    Measure = IF(MAX([Name]) = "A Bike Store" && MAX([Customer.StoreID]) = 934, "Working", "Not Working")

     

    Final Output:

     

    If there are still questions, please feel free to ask me.

     

    Best Regards,
    Yulia Xu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Prarabdha_07's avatar
      Prarabdha_07
      Frequent Visitor

      We don't want to merge as data is huge

      Will consider this as the last option 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Prarabdha_07 

       

      After my testing, you can put the BusinessEntityID field in place of the StoreID field in the visualization if you wish.

       

      Best Regards,
      Yulia Xu

       

      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Prarabdha_07 

       

      Does the method I provide work for you? If you have any further questions, please feel free to ask me.

       

      Best Regards,
      Yulia Xu