Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

create measure using two tables and if condition

Hi,

 

I have two tables similar like below :

 

Table1

Person CountryID Salary

Sachin Ind        100

Dhoni  Ind         200

Messi   Arg        300

Nadal   Sp         400

 

Table2

CountryName CountryId

India                Ind

Argentina        Arg

Spain               Sp

 

Table1 have M:1 relationship with Table2

 

I want to create Measure using condition Measure=IF(Table2.CountryName="India",Table1.Salary,9999)

I can create this using calculated column but want to create Measure as Table1 is huge.

 

Thanks

  • Anonymous's avatar
    Anonymous
    6 years ago
    [India Salary] =
    IF( SELECTEDVALUE( Table2[CountryName] ) = "India",
        SUM( Table1[Salary] ),
        9999
    )

7 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous - 

    Measure=IF(MAX(Table2[CountryName])="India",MAX(Table1[Salary]),9999)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Sorry but why you used MAX?

  • Anonymous 

    Please explain a bit more on what exactly you need to calculate. Do you want to get the total salary of all the players if you select India or the maximum, minimum ?

    ________________________

    Did I answer your question? Mark this post as a solution, this will help others!.

    Click on the Thumbs-Up icon on the right if you like this reply 🙂

    YouTube, LinkedIn 

    • Anonymous's avatar
      Anonymous
      Not applicable

      I want to calculate total salary of India.

      • Fowmy's avatar
        Fowmy
        Icon for Super User rankSuper User


        Anonymous 

        Try:

        Measure = CALCULATE( SUM(Table1.Salary),Table2.CountryName="India")


        ________________________

        Did I answer your question? Mark this post as a solution, this will help others!.

        Click on the Thumbs-Up icon on the right if you like this reply 🙂

        YouTube, LinkedIn

  • Anonymous ,

    Measure=IF(MAX(Table2[CountryName])="India",Sum(Table1[Salary]),9999)

  • Anonymous's avatar
    Anonymous
    Not applicable
    [India Salary] =
    IF( SELECTEDVALUE( Table2[CountryName] ) = "India",
        SUM( Table1[Salary] ),
        9999
    )