Forum Discussion
nirvana_moksh
8 years agoImpactful Individual
Max Row Based on Insert Date
Hello, So I have two solutions in place but they are causing some issues. Bascially, I have two tables: 1.) Table 1 has ID which is also present in Table 2 2.) Table 2 has ID and other data ...
- 8 years ago
This calculated table gets close. It looks long, but it's not that complicated. I have attached a PBIX file
Table = VAR x = SELECTCOLUMNS( Table2 , "IDx",[ID] , "TASK" ,[TASK] , "DURATIONx" , INT(SUBSTITUTE('Table2'[DURATION]," HRS","")) , "INSERT DATE",[INSERT DATE] ) VAR y = GROUPBY( x, [IDx], "MAX_DURATIONx", MAXX(CURRENTGROUP(),[DURATIONx]) ) VAR z= SELECTCOLUMNS( GENERATEALL( 'Table1', FILTER( y, [ID] = [IDx] ) ), "IDz",[ID], "MAX_DURATOINx",[MAX_DURATIONx] ) RETURN SELECTCOLUMNS( GENERATEALL( z, FILTER( 'Table2',[ID] = [ID] && [MAX_DURATOINx] & " HRS" = 'Table2'[DURATION] ) ), "ID",[IDz], "TASK",[TASK], "DURATION",[DURATION], "INSERT DATE",[INSERT DATE] ) - Anonymous8 years ago
Yes there are many sites which explains how to do this. For example,Please refer the below URL which explains the left outer join in DAX.
https://curbal.com/blog/joining-table-in-power-bi-with-power-query-and-dax
Thanks
Raj
Phil_Seamark
8 years agoMicrosoft Employee
This calculated table gets close. It looks long, but it's not that complicated. I have attached a PBIX file
Table =
VAR x = SELECTCOLUMNS(
Table2 ,
"IDx",[ID] ,
"TASK" ,[TASK] ,
"DURATIONx" ,
INT(SUBSTITUTE('Table2'[DURATION]," HRS","")) ,
"INSERT DATE",[INSERT DATE]
)
VAR y =
GROUPBY(
x,
[IDx],
"MAX_DURATIONx", MAXX(CURRENTGROUP(),[DURATIONx])
)
VAR z=
SELECTCOLUMNS(
GENERATEALL(
'Table1',
FILTER(
y,
[ID] = [IDx]
)
),
"IDz",[ID],
"MAX_DURATOINx",[MAX_DURATIONx]
)
RETURN
SELECTCOLUMNS(
GENERATEALL(
z,
FILTER(
'Table2',[ID] = [ID] &&
[MAX_DURATOINx] & " HRS" = 'Table2'[DURATION]
)
),
"ID",[IDz],
"TASK",[TASK],
"DURATION",[DURATION],
"INSERT DATE",[INSERT DATE]
)nirvana_moksh
8 years agoImpactful Individual
Giving this a shot, my actual tables have more data fields than I listed but hopefully my tweaks take them all.