Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Measure to concatenate more value using relationship

Hello all,

 

I have the following tables on my model

 

ProjectID_projectValue ID_projectID_oppo ID_oppoOpportunity
abc11 12 1A
dsc22 13 2A
sdf34 24 3B
ewe44 34 4B
dsd53 32 5B
fgt94 41 6C
trs03 77 7C
    83 8C
    98 9C
    09 0D

 

The relation is:

first 1:* second

second *:1 first

 

I need to obtain a measure that concatenate all projects belong to a Opportunity and a mesure that do sum of value of project for a Opportunity.

 

Result table:

Projects and total should be measures

 

OppoProjectsTotal
Aabc,sdf,ewe9
Babc,dsc,sdf7
Cfgt,trs7
D 0

 

I understand it is very difficult code. I even don't know if it is possible. any kind of idea o improvement is valued

 

Some help is very appreciated

 

many many thanks

  • Projects = CALCULATE( CONCATENATEX('Table 1', 'Table 1'[Project], ", "), TREATAS( VALUES( 'Table 2'[ID_project]),'Table 1'[ID_project]))
    
    Total = COALESCE( CALCULATE( SUM('Table 1'[Value]), TREATAS( VALUES('Table 2'[ID_project]),'Table 1'[ID_project])), 0)

3 Replies

  • Projects = CALCULATE( CONCATENATEX('Table 1', 'Table 1'[Project], ", "), TREATAS( VALUES( 'Table 2'[ID_project]),'Table 1'[ID_project]))
    
    Total = COALESCE( CALCULATE( SUM('Table 1'[Value]), TREATAS( VALUES('Table 2'[ID_project]),'Table 1'[ID_project])), 0)
    • Anonymous's avatar
      Anonymous
      Not applicable

      First of all, very thanks. 

       

      First formula works, the problema is total at the end of table that is giant, there is a way to deactivate total only for a mesaure?

      The secondo one doesn't work, all value are zero. Do you have any idea about this problem?

       

      johnt75 

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

        You can replace the first measure with

        Projects = IF( ISINSCOPE('Table 3'[Opportunity]), CALCULATE( CONCATENATEX('Table 1', 'Table 1'[Project], ", "), TREATAS( VALUES( 'Table 2'[ID_project]),'Table 1'[ID_project])))

        Not sure what might be wrong with the 2nd, as it works for me