Forum Discussion

mq2020's avatar
mq2020
Helper III
6 years ago
Solved

Create calculated column from a calculation in a different table

Hi!

 

I have a table (Table 1) with organisations and another table (Table 2) with users per organisation and whether they are claimin or not.

I want to add a calculated column in Table 1 (in blue below) to show the number of users claiming for each organisation (coming from Table 2). The common field in both tables is the organisation id.

 

How can I do this please? Thanks

 

Table 1 
OrganisationUsers Claiming
A1
B2

 

 

Table 2  
UserOrganisationUserClaiming Y/N
xAy
yAn
zBy
hBy

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi mq2020 ,

    Please try to create the following measure to get the flag of every organization with claim:

    Org Claiming YN = 
    VAR sumofClaimU =
        CALCULATE ( DISTINCTCOUNT ( 'User'[User] ), 'User'[User Claimed Y/N] = "y" )
    RETURN
        IF ( sumofClaimU > 0, "Y", "N" )

    Best Regards

    Rena

9 Replies

  • mq2020 assuming you have a relationship between these two tables on Organisation column, just add a measure and in table visual , drop organization and this new measure.

     

    Measure = 
    CALCULATE( COUNTROWS ( Table2 ), Table2[User Claiming] = "Y" )

     

    • mq2020's avatar
      mq2020
      Helper III

      Hi!

      I do have a relationship of 1 to Many.

      What I am trying to do is display a line chart with av.sales for 2 groups (Organisations with users claiming vs Organisations with users not claiming).

      The sales are in a 3rd table with has a relationship of Many to 1 with Table 1 (Organisations) so I end up with:

      Sales (Many to 1) -> Organisations (1 to Many) -> Users

      When i put together info from the sales table and the Users table it is not working, hence, I figured, it may be easier if i add the column I need in the Organisations table (i.e if that organisation has any user claiming)

       

      Thanks,

       

       

       

       

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi mq2020 ,

        Could you please provide some sample data in table "Sales"(exclude sensitive data)? What's your expected result? What you want is to get the average of sales? If yes, then whether it need to calculate based on certain conditions?


        What I am trying to do is display a line chart with av.sales for 2 groups (Organisations with users claiming vs Organisations with users not claiming).

        Best Regards

        Rena