Forum Discussion

dexter2424's avatar
dexter2424
Icon for Helper I rankHelper I
5 years ago
Solved

Distinct Count Total issue based on Type and latest period

Hi All,    I'm struggling with an issue, maybe it's easy to solve, or not, but I'm get lost, and the distinctcount doesn't work properly for me. I have the following table Policy Number Rep...
  • DataInsights's avatar
    5 years ago

    dexter2424,

     

    Try this solution.

     

    1. Create date table with a relationship to the data table:

     

     

    2. Create measure:

     

    Large = 
    VAR vSlicerEndDate =
        LASTDATE ( ALLSELECTED ( Dates[Date] ) )
    VAR vResult =
        SUMX (
            VALUES ( FactTable[Policy Number] ),
            VAR vMaxDate =
                CALCULATE (
                    MAX ( FactTable[Reporting Period] ),
                    FactTable[Reporting Period] <= vSlicerEndDate
                )
            VAR vType =
                CALCULATE ( MAX ( FactTable[Type] ), FactTable[Reporting Period] = vMaxDate )
            RETURN
                IF ( vType = "Large", 1, 0 )
        )
    RETURN
        vResult

     

    3. Create date slicer using the date table (Dates[Date]).

     

    4. Create visual:

     

     

    ---------------------------------------------

     

     

    ---------------------------------------------