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

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

Reply
velvetine_123
Frequent Visitor

Create summarized tables with 2 dimensions from multiple tables

Hi,

 

I'm looking to create a summarize table based on the following :

Table A :

DateCategorySales
1/1/2024A10
1/1/2024B15
2/1/2024A12

 

 

Table B :

DateCategoryCost
1/1/2024B5
2/1/2024C4
2/1/2024A3

 

Dimension Table Date :

Date

1/1/2024

2/1/2024

3/1/2024

 

Dimension Table Category :

Category
A
B
C

 

The intended outcome based on the summarize table should look like this :

 

Table Summarized :

DateCategorySalesCost
1/1/2024A10 
1/1/2024B155
2/1/2024A123
2/1/2024C 4

 

Appreciate any help !

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @velvetine_123 ,

Please try below code:-

SummarizedTable =
VAR _uni =
    UNION (
        SELECTCOLUMNS (
            'Table A',
            "Date", 'Table A'[Date],
            "Category", 'Table A'[Category],
            "Sales", 'Table A'[Sales],
            "Cost", BLANK ()
        ),
        SELECTCOLUMNS (
            'Table B',
            "Date", 'Table B'[Date],
            "Category", 'Table B'[Category],
            "Sales", BLANK (),
            "Cost", 'Table B'[Cost]
        )
    )
RETURN
    SUMMARIZE (
        _uni,
        [Date],
        [Category],
        "Sales",
            SUMX (
                FILTER (
                    _uni,
                    [Date] = EARLIER ( [Date] )
                        && [Category] = EARLIER ( [Category] )
                ),
                [Sales]
            ),
        "Cost",
            SUMX (
                FILTER (
                    _uni,
                    [Date] = EARLIER ( [Date] )
                        && [Category] = EARLIER ( [Category] )
                ),
                [Cost]
            )
    )

Samarth_18_0-1721366421620.png

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

3 REPLIES 3
Samarth_18
Community Champion
Community Champion

Hi @velvetine_123 ,

Please try below code:-

SummarizedTable =
VAR _uni =
    UNION (
        SELECTCOLUMNS (
            'Table A',
            "Date", 'Table A'[Date],
            "Category", 'Table A'[Category],
            "Sales", 'Table A'[Sales],
            "Cost", BLANK ()
        ),
        SELECTCOLUMNS (
            'Table B',
            "Date", 'Table B'[Date],
            "Category", 'Table B'[Category],
            "Sales", BLANK (),
            "Cost", 'Table B'[Cost]
        )
    )
RETURN
    SUMMARIZE (
        _uni,
        [Date],
        [Category],
        "Sales",
            SUMX (
                FILTER (
                    _uni,
                    [Date] = EARLIER ( [Date] )
                        && [Category] = EARLIER ( [Category] )
                ),
                [Sales]
            ),
        "Cost",
            SUMX (
                FILTER (
                    _uni,
                    [Date] = EARLIER ( [Date] )
                        && [Category] = EARLIER ( [Category] )
                ),
                [Cost]
            )
    )

Samarth_18_0-1721366421620.png

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

bhanu_gautam
Super User
Super User

@velvetine_123 , Either you can use Join in Power Query to merge these tables by going to Home selecte merge query option or you can create summarized table by going to modelling view and selecting new table using below mentioned DAX

 

SummarizedTable =
SUMMARIZE(
    UNION(
        SELECTCOLUMNS(
            'Table A',
            "Date", 'Table A'[Date],
            "Category", 'Table A'[Category],
            "Sales", 'Table A'[Sales],
            "Cost", BLANK()
        ),
        SELECTCOLUMNS(
            'Table B',
            "Date", 'Table B'[Date],
            "Category", 'Table B'[Category],
            "Sales", BLANK(),
            "Cost", 'Table B'[Cost]
        )
    ),
    [Date], [Category],
    "Sales", SUMX(FILTER(UNION('Table A', 'Table B'), [Date] = EARLIER([Date]) && [Category] = EARLIER([Category])), [Sales]),
    "Cost", SUMX(FILTER(UNION('Table A', 'Table B'), [Date] = EARLIER([Date]) && [Category] = EARLIER([Category])), [Cost])



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hey thanks for your response, but i keep getting error saying the number the number of columns in UNION are not the same. I've been trying to figure it out but I cant. Wondering if you know what is that about ?

Helpful resources

Announcements
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.