Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

HELP: Matrix Column Subtotals Type different Summarization Type from Values

Hi Community, 

Is there a way to change the type for matrix subtotals ? 

Let me explain the issue I have. Imagine I have two tables

entities:

entity  country  value
aUK5
bUSA3
cUK8
.........

 

and a relationship table, noting type of relationship( can be either grant or loan)and the year it started between entities and investors, 

relationships:

entity  investor  year  type  

a

X2017loan
aX2020grant
aY2020grant
bY2018loan
bY2019loan
cX2019grant
cX2021grant
cY2017grant
............

 

 

now I want to have a relationship matrix, where I can filter by country, relationship type and year and always show the TOP N entities in terms of "value" after the applied filter.

 

For filter "UK","grant", starting from 2018, I will get the following matrix. The values are an added column called "is_related" with all 1 added to the relationship table. 

matrix visual:

investor  entity a   entity c  COLUMN SUBTOTAL
X123
Y1 1

 

The problem is the following: I do not want to count the relationship between X and entity c twice. If I select the type of Matrix values to be COUNT (DISTINCT) the column subtotal however also changes to distinct counts and will be 1 for all rows that have a value. 

I would want the column subtotal to be the sum of relationships for each investor. so in this case the subtotals should be 2 and 1 respectively. Any ideas how this could be solved?

11 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Anonymous 
    Here is the updated solution as per your requirement https://www.dropbox.com/t/4TYzPYWvbgrSkooo

    Count = 
    IF ( 
        ISINSCOPE (entities[entity] ),
        DISTINCTCOUNT ( relationships[investor] ),
        DISTINCTCOUNT (  relationships[entity] )
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much - this has been bothering me for quite some time.

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Anonymous 
    Which one is the correct result you are looking for?

    This 

    investor  entity a   entity c  COLUMN SUBTOTAL
    X122
    Y1 1

     

    Or this

    investor  entity a   entity c  COLUMN SUBTOTAL
    X111
    Y1 1
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi tamerj1 , thanks for the quick reply. What I am looking for is the first one. I want the subtotal to show the number of entries in each row.

    • tamerj1's avatar
      tamerj1
      Community Champion

      Hi Anonymous 
      Sorry my mistake. the 2nd matrix was wrong. Please double check and confirm which one

      This 

      investor  entity a   entity c  COLUMN SUBTOTAL
      X122
      Y1 1

       

      Or this

      investor  entity a   entity c  COLUMN SUBTOTAL
      X112
      Y1 1
      • Anonymous's avatar
        Anonymous
        Not applicable

        The second one. I want an entry in the matrix if any relationship exists like a boolean (0 or 1) in this case and the subtotal to be the sum of relationships for each investor. Thanks so much. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        I do not really care about the totals per entity. This shows how many relationship each entity has, but it still only shows that each investor has only 1 relationship in total, although X has two relationships (with a and c)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Sadly your solution has exactly the same issue I have. The total for investor X is 1, altough it should be 2 (investor X has a grant relationship with a and with c, so 2 in total) . Any idea how to solve that? 

  • tamerj1's avatar
    tamerj1
    Community Champion

    Anonymous 
    Here is the solution with correct grand total https://www.dropbox.com/t/On3l9e4jULU2pm5B

    Count = 
    SUMX (
        SUMMARIZE (
            relationships,
            entities[entity],
            relationships[investor]
        ),
        CALCULATE (
            IF ( 
                ISINSCOPE (entities[entity] ),
                DISTINCTCOUNT ( relationships[investor] ),
                DISTINCTCOUNT (  relationships[entity] )
            )
        )
    )