Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Create a measure using relations and performing a multiplication

Having three tables, i need to come up with a measure that does a multiplication using values from those three tables, however making use of the existing relationships.

 

Article

IdNameValue
1aaa1
2bbb2

 

ArticleDetail1

IdArticleIdValue2
610.5
720.6

 

ArticleDetail2

IdArticleIdValue3
412
52

3

 

 

 

 

Article, ArticleDetail1 and ArticleDetail2 are linked using the Id->ArticleId columns.

I need to get Value * Value2 * Value3

So for aaa i get 1 * 0.5 * 2 = 1, for bbb i get 2 * 0.6 * 3 = 3.6

And in total, using this on a card, i would get 4.6. What does the DAX look like for this?

 

 

 

  • Hi,

    I am not sure how your datamodel looks like, but I assume the relationship looks like below.

    Please check the below picture and the attached pbix file.

     

     

     

     

     

    Expected result measure: =
    SUMX (
        Article,
        Article[Value]
            * SUMX ( RELATEDTABLE ( ArticleDetail1 ), ArticleDetail1[Value2] )
            * SUMX ( RELATEDTABLE ( ArticleDetail2 ), ArticleDetail2[Value3] )
    )
    

     

3 Replies

  • Are the relationships from Article one-to-many or one-to-one? If they are one-to-many, which value from the many side should the calculation use?

  • Hi,

    I am not sure how your datamodel looks like, but I assume the relationship looks like below.

    Please check the below picture and the attached pbix file.

     

     

     

     

     

    Expected result measure: =
    SUMX (
        Article,
        Article[Value]
            * SUMX ( RELATEDTABLE ( ArticleDetail1 ), ArticleDetail1[Value2] )
            * SUMX ( RELATEDTABLE ( ArticleDetail2 ), ArticleDetail2[Value3] )
    )
    

     

  • AndresOH's avatar
    AndresOH
    Frequent Visitor

    Hello, how would you do this measure if you need to add an if condiction? For example, only multiply if Article Id > 2.