Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Power BI Desktop

Hi,

 

I need some assistance to write a formula to compare two columns in different tables in Power BI

  • Hi Anonymous ,
    Do you mean like this?

    excepttable = except(values('Table2'[Country]),values('Table1'[Country]))

    This shows those countries in table 2 that are not in table 1.


    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πŸ‘are nice too.
    Nathaniel

5 Replies

  • Nathaniel_C's avatar
    Nathaniel_C
    Community Champion

    Hi Anonymous ,
    Do you mean like this?

    excepttable = except(values('Table2'[Country]),values('Table1'[Country]))

    This shows those countries in table 2 that are not in table 1.


    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πŸ‘are nice too.
    Nathaniel

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Nathaniel_C ,

       

      Thanks for your help. I got my resolution, but this query also works:

       

      excepttable = except(Table2,Table1)
       
      I got this as output:

      It resolved my query. Thanks for your help again!!!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Nathaniel,

       

      Thanks for your response. Here, is the dummy data:

       

      Table 1:

       

      PrefixCountryCount
      AABC2
      BFHG4
      CKJL5
      DSGH6
      EYUI4
      FKJH9

       

      Table 2:

      PrefixCountryCount
      AABC2
      BFHG4
      CKJL5
      GBNM3
      DSGH6
      HJKL8
      EYUI4
      FKJH9

       

      I need to write a formula to compare two columns (Country) from the above 2 tables in Power BI

      • Nathaniel_C's avatar
        Nathaniel_C
        Community Champion

        Hi Anonymous , not sure what you mean when you say compare two columns.  Do you mean how many more countries are in table 2?
        If so, try this:

        More Countries in T2 compared to T1 =
        VAR _t1Country =
            COUNT ( Table1[Country] )
        VAR _t2Country =
            COUNT ( Table2[Country] )
        RETURN
            _t2Country - _t1Country
        


        Let me know if you have any questions.

        If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πŸ‘are nice too.
        Nathaniel