Forum Discussion
left outer join using dax, Multiple to Multiple
- 9 years ago
Just playing around with CROSSJOIN and UNION as well and maybe a GENERATE using the nonexisting and ROW to provide space for the BLANK value :-) but now I have to take some sleep
- 9 years ago
Using DAX you can do something like this, but M is probably preferable.
Result = GENERATEALL ( 'Table 1', VAR Table1ID = 'Table 1'[id] RETURN SELECTCOLUMNS ( CALCULATETABLE ( 'Table 2', 'Table 2'[id] = Table1ID ), "price", 'Table 2'[price] ) ) - 9 years ago
Something like this should work. I tested it in a dummy model with physical tables Transformed_TAR, Tostr and 'Table 2' and it worked for me.
Note that I've left you VAR Table1... unchanged except that I've been pedantic and qualified all your column names from Transformed_TAR and Tostr with their table names, e.g. [tag] becomes Transformed_Tar[tag] :
Result = VAR Table1 = UNION ( SELECTCOLUMNS ( FILTER ( Transformed_TAR, Transformed_TAR[current] = "yes" && Transformed_TAR[rem_qty] <> 0 && Transformed_TAR[project phase] = "cons" && Transformed_TAR[P6 ACTIVITY ID] <> BLANK () ), "tag", Transformed_TAR[tag], "id", Transformed_TAR[P6 ACTIVITY ID], "subscan", Transformed_TAR[subscan], "subsystem", Transformed_TAR[TOSTR_Subsystem], "area", Transformed_TAR[Transformed Area], "weight", Transformed_TAR[weight], "drawing", Transformed_TAR[drawing], "phase", Transformed_TAR[project phase], "CREW", Transformed_TAR[crew], "Module", Transformed_TAR[Module], "rem_qty", Transformed_TAR[rem_qty] ), SELECTCOLUMNS ( FILTER ( Tostr, Tostr[remaining_ITR] <> 0 && Tostr[P6 activity id] <> BLANK () ), "tag", Tostr[tag], "id", Tostr[P6 activity id], "subscan", Tostr[subscan], "subsystem", Tostr[SUBSYSTEM], "area", Tostr[Area], "weight", Tostr[weight], "drawing", Tostr[SHEET], "phase", Tostr[Phase], "CREW", Tostr[crew], "Module", Tostr[Module], "rem_qty", Tostr[remaining_ITR] ) ) RETURN GENERATEALL ( Table1, VAR Table1ID = [id] RETURN SELECTCOLUMNS ( CALCULATETABLE ( 'Table 2', 'Table 2'[id] = Table1ID ), "price", 'Table 2'[price] ) )
Anonymous
If I understand you correctly, you should be able to do something like this, using FILTER instead of CALCULATETABLE.
Result =
VAR table_2 =
SELECTCOLUMNS ( 'Table 2', "id", 'Table 2'[id], "price", 'Table 2'[price] )
RETURN
GENERATEALL (
'Table 1',
VAR Table1ID = 'Table 1'[id]
RETURN
SELECTCOLUMNS ( FILTER ( table_2, [id] = Table1ID ), "price", [price] )
)I have assumed we start with the same physical tables as Mim's example and make table_2 a virtual table as you've described. Table 1 could also be a virtual table and it would make little difference.
Hi
I need to replace null\blank values from generateall ( null values from the Right Table ( Table2)) with 0 ( Zero).
Column1 ( from right Table) is whole number.
I have tried
Column1+ 0
IF(isblank(Table2[Column1],0, Table2[Column1])
But it is still showing Empty string\Blank Values.
Also, no calculations working on this Blank\Empty string. like Addition, subtraction,comparision on Blank Values. Calculation working if it has some values.
Could you please suggest solution?
- Anonymous6 years agoNot applicable
Hi OwenAuger
I need to replace null\blank values from generateall ( null values from the Right Table ( Table2)) with 0 ( Zero).
Column1 ( from right Table) is whole number.
I have tried
Column1+ 0
IF(isblank(Table2[Column1],0, Table2[Column1])
But it is still showing Empty string\Blank Values.
Also, no calculations working on this Blank\Empty string. like Addition, subtraction,comparision on Blank Values. Calculation working if it has some values.
Could you please suggest solution?
- Anonymous6 years agoNot applicable
This has been solved by keeping the results into Selectedcolumns or storing in physical table( This Null values has been modified as blank() values)