cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
neelofarshama
Post Partisan
Post Partisan

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 @neelofarshama ,

 

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 @neelofarshama ,

 

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

@neelofarshama , 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

 

 



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors