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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Difference of the 2 columns to create a new column

Hi,

I have a requirement where there are 2 tables Oct_20 and May_22. The first table is Oct table and second is May table. My requirement is to get a new table with difference of these two tables. Like for 2012 0-3 = -3(Laptop), 26-67=-41(Workstation) for 2013 2-26=-24(laptop), 8-14=-6(Workstation) and so on. Please suggest on how to achieve this.

 

neelofarshama_0-1652909373697.png

This is how the data looks like in each table as shown below. I need to find diff between count of asset type in 1st table and count of asset type in seconf table table.

neelofarshama_2-1652909918290.png 

neelofarshama_3-1652910141772.png

Thanks in Advance,

Neelofar.

 

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please create the table.

 

 

NewTable = 
VAR tab =
    DISTINCT (
        UNION (
            SUMMARIZE ( May_22, May_22[Model Year], May_22[Type] ),
            SUMMARIZE ( Oct_20, Oct_20[Model Year], Oct_20[Asset Type] )
        )
    )
RETURN
    ADDCOLUMNS (
        tab,
        "DiffValue",
            CALCULATE (
                SUM ( May_22[Count of Type] ),
                FILTER (
                    May_22,
                    May_22[Type] = EARLIER ( [Type] )
                        && May_22[Model Year] = EARLIER ( [Model Year] )
                )
            )
                - CALCULATE (
                    SUM ( Oct_20[Count of Asset Type] ),
                    FILTER (
                        Oct_20,
                        Oct_20[Asset Type] = EARLIER ( [Type] )
                            && Oct_20[Model Year] = EARLIER ( [Model Year] )
                    )
                )
    )

vkkfmsft_0-1653383813196.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please create the table.

 

 

NewTable = 
VAR tab =
    DISTINCT (
        UNION (
            SUMMARIZE ( May_22, May_22[Model Year], May_22[Type] ),
            SUMMARIZE ( Oct_20, Oct_20[Model Year], Oct_20[Asset Type] )
        )
    )
RETURN
    ADDCOLUMNS (
        tab,
        "DiffValue",
            CALCULATE (
                SUM ( May_22[Count of Type] ),
                FILTER (
                    May_22,
                    May_22[Type] = EARLIER ( [Type] )
                        && May_22[Model Year] = EARLIER ( [Model Year] )
                )
            )
                - CALCULATE (
                    SUM ( Oct_20[Count of Asset Type] ),
                    FILTER (
                        Oct_20,
                        Oct_20[Asset Type] = EARLIER ( [Type] )
                            && Oct_20[Model Year] = EARLIER ( [Model Year] )
                    )
                )
    )

vkkfmsft_0-1653383813196.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Create common dimensions Type and model year, join with both tables and the use measure sum/ count of asset type from both tables in a visual

 

 

example

Type = distinct(union(distinct(Table1[Type]),distinct(Table2[Type])))

 

 

Use matrix visual, as per need

Bridge Table: https://www.youtube.com/watch?v=Bkf35Roman8&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=19

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors