Forum Discussion

pawelk3's avatar
pawelk3
Icon for Helper I rankHelper I
3 years ago
Solved

Count rows from related table (M2M)

Hi, I have two tables: 'Lead' and "Contact' with relation many to many using keys Lead[ParentContactId] and Contact[ContactId]. I want to create a measure in leads table to count number of matchin...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi pawelk3 ,

    It seems that what you are trying to create is a measure, please update the formula of measure[Conversions] as below. Later check if it can return your expected result...

    Conversions =
    VAR _seldate =
        SELECTEDVALUE ( Lead[CreatedOn] )
    RETURN
        CALCULATE (
            COUNT ( Contact[ContactId] ),
            FILTER (
                Contact,
                Contact[ContractDate] >= _seldate
                    && Contact[ContractDate] <= _seldate + 90
            )
        )

    In addition, you can review the following blog to know the common DAX errors...

    DAX error messages in Power BI

     

    If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format, your treemap Fields settings and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards