Forum Discussion

mespoKTM's avatar
mespoKTM
Regular Visitor
5 years ago
Solved

Calculated column sum from other table based on other column value

Hi, I'll try to explain what I need.

 

I have a table which contains some target value. I would calculate a value based on other table depending on "Cd_CACda" column.

 

So, this is the calculated column formula

 

 

 

Allocazione_1 = 
VAR ONF = CALCULATE(SUM(QUERY_CostiIndiretti[Importo]),TRIM(QUERY_CostiIndiretti[CentroAnalisi]) = "OF001")

RETURN
IF(Allocazione_Ordine[Cd_CACda] = "AMM001",VALUE(ONF),0)

 

 

 

 and this is the table

 

  • Please try:

     

    Allocazione_1 = 
    VAR ONF = CALCULATE(SUM(QUERY_CostiIndiretti[Importo]),
    FILTER(ALL(QUERY_CostiIndiretti),
    QUERY_CostiIndiretti[CentroAnalisi] = "OF001"))
    
    RETURN
    IF(Allocazione_Ordine[Cd_CACda] = "AMM001",ONF,0)

     

    If the problem persists,could you share the sample pbix with dummy data?

    Please remove any sensitive data before uploading.

3 Replies

    • mespoKTM's avatar
      mespoKTM
      Regular Visitor

      Hi amitchandak , thank you for reply. There is a relationship through registry table.

       

      For example: in the column "Allocazione_1" I want the sum of value related to "ONF001" from another table. The other table is this:

       

       

  • V-lianl-msft's avatar
    V-lianl-msft
    Icon for Community Support rankCommunity Support

    Please try:

     

    Allocazione_1 = 
    VAR ONF = CALCULATE(SUM(QUERY_CostiIndiretti[Importo]),
    FILTER(ALL(QUERY_CostiIndiretti),
    QUERY_CostiIndiretti[CentroAnalisi] = "OF001"))
    
    RETURN
    IF(Allocazione_Ordine[Cd_CACda] = "AMM001",ONF,0)

     

    If the problem persists,could you share the sample pbix with dummy data?

    Please remove any sensitive data before uploading.