Forum Discussion
Anonymous
6 years agoNot applicable
How to alias table like in SQL?
Hi All,
We want to perform left outer join in DAX Query Designer using this script:
EVALUATE
NATURALLEFTOUTERJOIN
(
SUMMARIZECOLUMNS ( 'Store Invoice'[Store Id],
'Store Invoice'[Store Name],
'Execution Product'[Sub Brand],
FILTER (
'Date',
'Date'[Year]
>= YEAR ( NOW () ) - 1
&& 'Date'[Year] <= YEAR ( NOW () )
),
FILTER (
'Management Responsibility Area',
'Management Responsibility Area'[MRA Code] = @MRACode
),
"Gross Amt", [Net Secondary Amount - Invoiced],
"Gross Returns Amt", [Total Returns Amount]
)
,
SUMMARIZECOLUMNS ( 'Store Invoice'[Store Id],
'Local Store Hierarchy'[Hierarchy Name],
FILTER (
'Date',
'Date'[Year]
>= YEAR ( NOW () ) - 1
&& 'Date'[Year] <= YEAR ( NOW () )
),
FILTER (
'Management Responsibility Area',
'Management Responsibility Area'[MRA Code] = @MRACode
),
FILTER (
'Local Store Hierarchy',
'Local Store Hierarchy'[Hierarchy Name] = @StoreHierarchyName
),
"Qty",[Net Secondary Quantity - Invoiced (EA)]
)
NATURALLEFTOUTERJOIN
(
SUMMARIZECOLUMNS ( 'Store Invoice'[Store Id],
'Store Invoice'[Store Name],
'Execution Product'[Sub Brand],
FILTER (
'Date',
'Date'[Year]
>= YEAR ( NOW () ) - 1
&& 'Date'[Year] <= YEAR ( NOW () )
),
FILTER (
'Management Responsibility Area',
'Management Responsibility Area'[MRA Code] = @MRACode
),
"Gross Amt", [Net Secondary Amount - Invoiced],
"Gross Returns Amt", [Total Returns Amount]
)
,
SUMMARIZECOLUMNS ( 'Store Invoice'[Store Id],
'Local Store Hierarchy'[Hierarchy Name],
FILTER (
'Date',
'Date'[Year]
>= YEAR ( NOW () ) - 1
&& 'Date'[Year] <= YEAR ( NOW () )
),
FILTER (
'Management Responsibility Area',
'Management Responsibility Area'[MRA Code] = @MRACode
),
FILTER (
'Local Store Hierarchy',
'Local Store Hierarchy'[Hierarchy Name] = @StoreHierarchyName
),
"Qty",[Net Secondary Quantity - Invoiced (EA)]
)
)
Its seems that NATURALLEFTOUTERJOIN could'nt fix the problem.
We want to create an Alias for this table like we can do in sql. Below is the script:
SUMMARIZECOLUMNS ( 'Store Invoice'[Store Id],
'Local Store Hierarchy'[Hierarchy Name],
FILTER (
'Date',
'Date'[Year]
>= YEAR ( NOW () ) - 1
&& 'Date'[Year] <= YEAR ( NOW () )
),
FILTER (
'Management Responsibility Area',
'Management Responsibility Area'[MRA Code] = @MRACode
),
FILTER (
'Local Store Hierarchy',
'Local Store Hierarchy'[Hierarchy Name] = @StoreHierarchyName
),
"Qty",[Net Secondary Quantity - Invoiced (EA)]
)
'Local Store Hierarchy'[Hierarchy Name],
FILTER (
'Date',
'Date'[Year]
>= YEAR ( NOW () ) - 1
&& 'Date'[Year] <= YEAR ( NOW () )
),
FILTER (
'Management Responsibility Area',
'Management Responsibility Area'[MRA Code] = @MRACode
),
FILTER (
'Local Store Hierarchy',
'Local Store Hierarchy'[Hierarchy Name] = @StoreHierarchyName
),
"Qty",[Net Secondary Quantity - Invoiced (EA)]
)
)
Thanks and Regards,
Ian
2 Replies
- AnonymousNot applicable
Can you explain what is your exact requirement.
share some sample data and expected output.
Answer to your quetion is you can store table in variable like this
New table
=
var a= table1
var b=table 2
return
NATURALLEFTOUTERJOIN(a,b)
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.check my blog here
https://community.powerbi.com/t5/Community-Blog/Connecting-to-a-Tabular-Model-Using-Power-BI/ba-p/913784- AnonymousNot applicable
Hi Pravin,
We want to create this in SSRS not on the Power Bi side. We're using DAX Query. Is this possible?
Thanks and Regars,
Ian