Forum Discussion
Join Two Table but with different granularity
- 8 years ago
Hi Ashish,
Thanks for the solution. I can see that the general step you did: merge the query first, put the index, and update the value where the index is not 0.
however, I am looking the solution in DAX formula, bc my powerBI will use live connection SSAS, so the power query options will not available there.
Thanks
Andre
Hi Ashish,
Thanks for the solution. I can see that the general step you did: merge the query first, put the index, and update the value where the index is not 0.
however, I am looking the solution in DAX formula, bc my powerBI will use live connection SSAS, so the power query options will not available there.
Thanks
Andre
EVALUATE
VAR T1 =
SELECTCOLUMNS (
ADDCOLUMNS (
Table1,
"Key", Table1[Date] & Table1[Category],
"Subrank", VALUE ( MID ( Table1[SubCategory], 2, 15 ) )
),
"Key", [Key],
"Date", [Date],
"Major Category", [Major Category],
"Category", [Category],
"SubCategory", [Subcategory],
"Subrank", [Subrank]
)
VAR T2 =
SELECTCOLUMNS (
ADDCOLUMNS ( Table2, "Key", Table2[Date] & Table2[Category] ),
"Key", [Key],
"Target", [Target]
)
VAR T3 =
NATURALLEFTOUTERJOIN ( T1, T2 )
VAR T4 =
ADDCOLUMNS (
T3,
"Rank", VAR Ke = [Key] RETURN MINX(FILTER ( T3, [key] = Ke ),[Subrank] )=[Subrank])
VAR T5 = ADDCOLUMNS(T4,"RevisedTarget", [Target] * [Rank])
RETURN
SELECTCOLUMNS(T5,
"Date", [Date],
"Major Category", [Major Category],
"Category", [Category],
"SubCategory", [Subcategory],
"Target", [RevisedTarget]
)