Forum Discussion

Rdarshana's avatar
Rdarshana
Helper II
2 years ago
Solved

Formula Explanation

Hi, Can someone explain to me what this formula does -  ID Count = COUNTROWS(DISTINCT(SELECTCOLUMNS('Fact 1', "ID Column", RELATED('Dim 2 '[ID Column])))) From what I understand, we are pic...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Rdarshana ,

    I created a sample pbix file(see the attachment), you can find the details in it. And for below formula, it will return the count of ID in the table 'Fact 1' which ID also in the dimenison table 'Dim 2'. However, it will also include the IDs in 'Fact 1' table which not exist in the table 'Dim 2' as blank values. All these blank values count as 1. Please check the below screenshot:

    ID Count = COUNTROWS(DISTINCT(SELECTCOLUMNS('Fact 1', "ID Column", RELATED('Dim 2 '[ID Column]))))

    So you can update the forumula as below to get the correct count of ids.

    ID Count_new =
    COUNTROWS (
        FILTER (
            DISTINCT (
                SELECTCOLUMNS ( 'Fact 1', "ID Column", RELATED ( 'Dim 2'[Dim ID] ) )
            ),
            [ID Column] <> BLANK ()
        )
    )

    Best Regards