Forum Discussion

SRHR's avatar
SRHR
Regular Visitor
4 months ago
Solved

DAX Measure for Ranking the valid rows and calculating the average rating

Hi, Appreciate any help. I have two tables – Attendance, Survey I don’t have any joining keys other than email and no way of determining to which survey they responded to if the same MS forms are u...
  • krishnakanth240's avatar
    4 months ago

    Hi SRHR 

    Can you try these

     

    Rank Valid Measure =

    VAR LearningDate = SELECTEDVALUE(Attendance[Learning Date])

    VAR Email = SELECTEDVALUE(Attendance[Email])

    VAR FormKey = SELECTEDVALUE(Attendance[Form Key])

    RETURN

    IF(SELECTEDVALUE(Attendance[Status]) = "Completed" &&CALCULATE(

    COUNTROWS(Survey),

    FILTER(

                Survey,

                Survey[Email] = Email &&

                Survey[Form Key] = FormKey &&

                Survey[Survey Date] >= LearningDate &&

                Survey[Survey Date] <= LearningDate + 2

            ) ) > 0,1,0)

     

    Avg Rating Measure =

    AVERAGEX(FILTER(

    Survey,

    VAR MatchLearningDate =

    CALCULATE(MAX(Attendance[Learning Date]),

    FILTER(

                        Attendance,

                        Attendance[Email] = Survey[Email] &&

                        Attendance[Form Key] = Survey[Form Key] && Attendance[Status] = "Completed"))

    RETURN

    NOT ISBLANK(MatchLearningDate) && Survey[Survey Date] >= MatchLearningDate &&

    Survey[Survey Date] <= MatchLearningDate + 2),

    Survey[Rating])

  • pcoley's avatar
    4 months ago

    I understand the challenge of linking survey responses without a clear identifier.

    Valid Survey Rank =
    CALCULATE (
        COUNTROWS ( Survey ),
        FILTER (
            Survey,
            Survey[Email]
                = EARLIER ( Attendance[Email] )
                && Survey[Form Key]
                    = EARLIER ( Attendance[Form Key] )
                && Survey[Survey Date] > Attendance[Learning Date]
        )
    )

     

     This formula counts survey responses where the date is after the learning date for the same email and form.