Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Cross Table If Statements?

Hi All, 

Only started with PowerBI last week so go easy on me!

 

I have tables like the below added:

 

Table A 
IDName
1A
2B
3C

 

Table B 
IDModel
1800
2HP 850
3Dell 900

 

Table C 
IDRAM
18GB
216GB
34GB

 

 

Table D 
IDHDD Type
1HDD
2SSD
3Unknown

 

There is a many to many relationship setup between A>BCD where BCD filter A.  Tables B,C + D contain many more ID's than Table A.

 

I need to create a new column in Table A (I think?) that I can do some if filtering on across BCD.  So for instance a couple variations would be:

IF ID= HDD=4GB Then "REPLACE"

IF ID= SSD=8GB Then "REUSE"

IF ID= SSD=8GB AND Model=800 Then "REPLACE"

etc

 

I cannot figure out how to do this!  When I add a new column into A I dont seem to be able to bring in columns from the other tables.

 

Any help would be greatly appreciated!

  • Hi Anonymous 

     

    1. Try Merge Queries like in the video below.
    2. Or if you wont to preserve the model and add columns from different tables use RELATED or RELATEDTABLE DAX functions.

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski

     

4 Replies

  • Mariusz's avatar
    Mariusz
    Community Champion

    Hi Anonymous 

     

    1. Try Merge Queries like in the video below.
    2. Or if you wont to preserve the model and add columns from different tables use RELATED or RELATEDTABLE DAX functions.

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Mariusz,

       

      Related hasnt worked due to the relationships, and I'll be damned if I can get RelatedTable to work in the way I'm after.

       

      For instance, if the below is a normal query, how would I turn this into using the RelatedTable? - where v_GS_DISK[Caption0groups] is the RelatedTable.

       

      Support = IF(FIND("HDD",v_GS_DISK[Caption0groups], 1,BLANK()),"Replace")

       

      Started looking at Merging.  Its an option i'll continue to explore.  A couple questions however;

       

      1) Does the data in the merge update when the sources brings in new information?

      2) Is it posible to merge a group?  i.e in Table B I have a group i've made from a column.  But when I merge Table B to Table A, its not an option.  It took a reaaaly long time to make some of those groups and I reaaaly dont want to make them again manually in Table A post merge.

       

      Thanks,

      Rich

      • coachVE's avatar
        coachVE
        Frequent Visitor

        1) Yes, the merge is happening with each refresh and should normally be done in the beginning. 
        Extract->Transform->Load
        2) because the merge is done in the beginning, you cannot use grouping or other columns you created after.