Forum Discussion

andybamber's avatar
andybamber
Helper III
5 years ago
Solved

Row Context

Hello!   Hopefully someone can help me with an issue im facing. In the PBIX below I have a sample of my dataset. If you look at the visuals, the first one correctly shows a distinct count of 8... t...
  • mahoneypat's avatar
    mahoneypat
    5 years ago

    Here is one way to do it.  This makes a virtual table of each resource and two columns - the max date within this role and the max date across all roles.  It then counts only those where those snapshot dates are the same.

     

    NewMeasure =
    VAR summary =
        ADDCOLUMNS (
            DISTINCT ( Sheet1[resource_key] ),
            "@maxdate",
                CALCULATE (
                    MAX ( Sheet1[snaphot_stamp] )
                ),
            "@maxall",
                CALCULATE (
                    MAX ( Sheet1[snaphot_stamp] ),
                    ALL ( Sheet1[primary_role] )
                )
        )
    RETURN
        COUNTROWS (
            FILTER (
                summary,
                [@maxdate] = [@maxall]
            )
        )

     

    Regards,

    Pat