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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
markmess77
Resolver I
Resolver I

How to best join tables together with DAX?

I am creating a table with DAX, which is essentially joining two different tables. Sorry for the bit of a wall of DAX, but here is what I am using for reference:

 

 

Joined Table = 
VAR Table1 =
    GENERATE(
        VALUES('Fact_Table_1'[Year-Month]),
        UNION (
            ADDCOLUMNS (
                Column,
                "Result 1", [Measure 1] - (CALCULATE([Measure 1], DATEADD(Fact_Table_1[Year-Month], -1, YEAR))),
                "Calculation Type", "LY",
                "Key", FORMAT (Fact_Table_1[Year-Month], "yyyymmdd" & "LY")
            ),
            ADDCOLUMNS (
                Column',
                "Result 1", [Measure 1] - (CALCULATE([Measure 1], DATEADD(Fact_Table_1[Year-Month], -1, QUARTER))),
                "Calculation Type", "LQ",
                "Key", FORMAT (Fact_Table_1[Year-Month], "yyyymmdd" & "LQ")
            ),
            ADDCOLUMNS (
                Column,
                "Result 1", [Measure 1] - (CALCULATE([Measure 1], DATEADD(Fact_Table_1[Year-Month], -1, MONTH))),
                "Calculation Type", "LM",
                "Key", FORMAT (Fact_Table_1[Year-Month], "yyyymmdd" & "LM")
            )
        )
    )
VAR Table2 =
    GENERATE(
        DISTINCT(Fact_Table_2[Date]),
        UNION (
            ADDCOLUMNS (
                Column,
                "Result 2", [Measure 2] - (CALCULATE([Measure 2], DATEADD(Fact_Table_2[Date], -1, YEAR))),
                "Calculation Type", "LY",
                "Key", FORMAT (Fact_Table_2[Date], "yyyymmdd" & "LY")
            ),
            ADDCOLUMNS (
                Column,
                "Result 2", [Measure 2] - (CALCULATE([Measure 2], DATEADD(Fact_Table_2[Date], -1, QUARTER))),
                "Calculation Type", "LQ",
                "Key", FORMAT (Fact_Table_2[Date], "yyyymmdd" & "LQ")
            ),
            ADDCOLUMNS (
                Column,
                "Result 2", [Measure 2] - (CALCULATE([Measure 2], DATEADD(Fact_Table_2[Date], -1, MONTH))),
                "Calculation Type", "LM",
                "Key", FORMAT (Fact_Table_2[Date], "yyyymmdd" & "LM")
            )
        )
    )

RETURN
NATURALINNERJOIN (
    Table1, Table2
)

 

 

This returns my expected result, but the join function throws an error when the date columns of each fact table has the same name. As such, I had to rename one of my date columns for this to work. So my end result is a table with two identical date columns, like this example below:

delete.PNG

Within my DAX expression, I need to refer to the date column within the relative fact table to get the correct result for the time intelligence calculations. However, it is unnecessary to include two identical date columns in the same table.

I feel like I must be missing something simple.

Is there a way I can modify my DAX to only return one date column? Or at the very least drop one of the date columns?  

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@markmess77 - Use SELECTCOLUMNS to overcome name duplicates.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@markmess77 - Use SELECTCOLUMNS to overcome name duplicates.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.