Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Need help to convert this LEFT JOIN

Hi Floks,
I very tried of trying to convert this query to DAX.
Can anybody please help to get out of this.

My Query:

select * from
(Select B.SiteID, B.PartID, A.Length, A.Width
from factInventoryTransactions A join dimpart B
on A.Part_SK = B.Part_SK

where A.TransactionType in(6,4) 
) Z

left join
(Select B.PartID, A.Length, A.Width
from factInventoryTransactions A join dimpart B on A.Part_SK = B.Part_SK
) Y
on Z.PartID = Y.PartID and Z.Length = Y.Length and Z.Width = Y.Width

where A.TransactionType in(7,5)
where Y.PartID is null

Thanks in advance ,
Sivanesan C

1 ACCEPTED SOLUTION

@Anonymous assume you already got a dimpart table and factinventor Table in the model, and then try this code

Table3 =
VAR LeftTbl =
    SUMMARIZE (
        FILTER ( FactTable, FactTable[TransactionType] IN { "4", "6" } ),
        dimTable[SiteID],
        dimTable[PartID],
        FactTable[Length],
        FactTable[Width]
    )
VAR RightTbl =
    SELECTCOLUMNS (
        SUMMARIZE (
            FILTER ( FactTable, FactTable[TransactionType] IN { "5", "7" } ),
            dimTable[PartID],
            FactTable[Length],
            FactTable[Width]
        ),
        "rPartID", dimTable[PartID],
        "rLength", FactTable[Length],
        "rWidth", FactTable[Width]
    )
RETURN
    GENERATE (
        LeftTbl,
        FILTER (
            RightTbl,
            [rPartID] = dimTable[PartID]
                && [rLength] = FactTable[Length]
                && [rWidth] = FactTable[Width]
        )
    )

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , what is a formula you want to achieve using these joins, the second join with dim part needs a combined concatenated key . Also, join would be run time. so need to know why we want to join parts in both queries

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi @amitchandak ,
First of all the above query have msitake,Below query is I want to convert .

select * from
(Select B.SiteID, B.PartID, A.Length, A.Width
from factInventoryTransactions A join dimpart B
on A.Part_SK = B.Part_SK
where A.TransactionType in (6,4)
) Z

left join


(Select B.PartID, A.Length, A.Width
from factInventoryTransactions A join dimpart B on A.Part_SK = B.Part_SK
where A.TransactionType in(7,5)
) Y
on Z.PartID = Y.PartID and Z.Length = Y.Length and Z.Width = Y.Width
where Y.PartID is null

Here i trying to pick the un closed orders, this is the logic in SQL 
But i need to show it in Power BI.

Thanks,
Sivanesan C

@Anonymous assume you already got a dimpart table and factinventor Table in the model, and then try this code

Table3 =
VAR LeftTbl =
    SUMMARIZE (
        FILTER ( FactTable, FactTable[TransactionType] IN { "4", "6" } ),
        dimTable[SiteID],
        dimTable[PartID],
        FactTable[Length],
        FactTable[Width]
    )
VAR RightTbl =
    SELECTCOLUMNS (
        SUMMARIZE (
            FILTER ( FactTable, FactTable[TransactionType] IN { "5", "7" } ),
            dimTable[PartID],
            FactTable[Length],
            FactTable[Width]
        ),
        "rPartID", dimTable[PartID],
        "rLength", FactTable[Length],
        "rWidth", FactTable[Width]
    )
RETURN
    GENERATE (
        LeftTbl,
        FILTER (
            RightTbl,
            [rPartID] = dimTable[PartID]
                && [rLength] = FactTable[Length]
                && [rWidth] = FactTable[Width]
        )
    )
Anonymous
Not applicable

Hi @wdx223_Daniel ,
It helps me alot but i dont use it as it is.
Make some changes in Dataware House and used your DAX.
Thanks alot.

@Anonymous ,Can you share sample data and sample output in a table format? Or a sample pbix after removing sensitive data. I can replicate as DAX but measure in power bi need different approch

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.