none
DAX measure to count rows RRS feed

  • Question

  • Hello,
    There are three tables linked together in the model as follows:

    Table1
    --------
    Key
    EntityID

    Table2
    --------
    EntityID

    Table3
    ---------
    TypeName
    EntityID

    At present, there is an active relationship between table1 and Table2 on EntityID
    Table2 (1) --> (*) Table1 as 1 to many - single direction from Table2 to Table1
    Table2(1) --> (*) Table3 as 1 to many - single direction from Table2 to Table3

    What is the measure to show the count of rows in Key column for each of the TypeName
    Example:

    TypeName Count
    ---------------------
    A 15
    XMT 12
    ...

    Thnak you
    Thursday, October 3, 2019 10:08 AM

Answers

  • Hi,
    You can not do that as there is no active relationship between table1 and table3 and therefore it gives the same number for every row

    Have you tried this? Your relationships are setup as follows right?

    Because I get the following result when I double checked this.


    http://darren.gosbell.com - please mark correct answers

    • Marked as answer by arkiboys Friday, October 4, 2019 12:22 PM
    Friday, October 4, 2019 10:04 AM
    Moderator

All replies


  • What is the measure to show the count of rows in Key column for each of the TypeName
    Example:


    If you want a count of rows something like the following should work:

    =CALCULATE( COUNTROWS( table1 ) , Table3 )

    If you want a count of distinct values you would do the following:

    =CALCULATE( DISTINCTCOUNT( table1[Key] ) , Table3 )


    http://darren.gosbell.com - please mark correct answers

    Thursday, October 3, 2019 10:20 PM
    Moderator
  • Hi,
    You can not do that as there is no active relationship between table1 and table3 and therefore it gives the same number for every row
    • Edited by arkiboys Friday, October 4, 2019 8:03 AM
    Friday, October 4, 2019 7:57 AM
  • Hi,
    You can not do that as there is no active relationship between table1 and table3 and therefore it gives the same number for every row

    Have you tried this? Your relationships are setup as follows right?

    Because I get the following result when I double checked this.


    http://darren.gosbell.com - please mark correct answers

    • Marked as answer by arkiboys Friday, October 4, 2019 12:22 PM
    Friday, October 4, 2019 10:04 AM
    Moderator
  • Thank you
    Friday, October 4, 2019 12:23 PM