Forum Discussion

Dhrutivyasa-070's avatar
3 years ago
Solved

DAX

Hello Community,  I have one Taste Rating dataset which contains following column. I want to compare one primary taster rating with other taster. and i want to slicer for taster name. One is for pr...
  • tamerj1's avatar
    3 years ago

    Hi Dhrutivyasa-070 
    Please refer to attached sample file with the proposed solution.

    Number of Lot Tasted = 
    VAR PrimaryTaster = SELECTEDVALUE ( Tasters[Primary Taster] )
    VAR Taster = SELECTEDVALUE ( 'Table'[TasterName], PrimaryTaster )
    RETURN
        IF (
            Taster <> PrimaryTaster,
            SUMX (
                VALUES ( 'Table'[UniqueID] ),
                INT (
                    PrimaryTaster 
                        IN CALCULATETABLE ( 
                            VALUES ( 'Table'[TasterName] ),
                            ALL ( 'Table'[TasterName] )
                        )
                )
            )
        )
    Match Lot = 
    VAR PrimaryTaster = SELECTEDVALUE ( Tasters[Primary Taster] )
    VAR Taster = SELECTEDVALUE ( 'Table'[TasterName], PrimaryTaster )
    RETURN
        IF (
            Taster <> PrimaryTaster,
            SUMX (
                SUMMARIZE ( 'Table', 'Table'[UniqueID], 'Table'[TastingScore] ),
                INT (
                    PrimaryTaster 
                        IN CALCULATETABLE ( 
                            VALUES ( 'Table'[TasterName] ),
                            ALL ( 'Table'[TasterName] )
                        )
                )
            )
        )
    % Match = DIVIDE ( [Match Lot], [Number of Lot Tasted] )