Forum Discussion

thmonte's avatar
thmonte
Icon for Helper IV rankHelper IV
8 years ago
Solved

Creating a value column for each time an item appears within a single date

I have a table that has the first 4 columns here.  I want to try and create a new column that breaks the "items' down to everytime they appear within a date range regardless of "Store".   so COUNT ...
  • v-yulgu-msft's avatar
    v-yulgu-msft
    8 years ago

    Hi thmonte,

     

    You could create a measure similar to:

    Column3 =
    VAR myCount1 =
        IF (
            Table3[Region] IN { "UK", "US" },
            0,
            (
                CALCULATE (
                    COUNTROWS ( 'Table3' ),
                    FILTER (
                        ALLEXCEPT ( 'Table3', Table3[Date] ),
                        Table3[Item 1] = EARLIER ( 'Table3'[Item 1] )
                            && Table3[Region] <> "US"
                            && Table3[Region] <> "UK"
                    )
                )
                    + CALCULATE (
                        COUNTROWS ( 'Table3' ),
                        FILTER (
                            ALLEXCEPT ( 'Table3', Table3[Date] ),
                            Table3[Item 2] = EARLIER ( 'Table3'[Item 1] )
                                && Table3[Region] <> "US"
                                && Table3[Region] <> "UK"
                        )
                    )
            )
        )
    VAR myCount1percent =
        IF ( 'Table3'[Item 1] <> "null", DIVIDE ( 1 / myCount1, 1 ), 0 )
    VAR myCount2 =
        IF (
            Table3[Region] IN { "UK", "US" },
            0,
            (
                CALCULATE (
                    COUNTROWS ( 'Table3' ),
                    FILTER (
                        ALLEXCEPT ( 'Table3', Table3[Date] ),
                        Table3[Item 1] = EARLIER ( 'Table3'[Item 2] )
                            && Table3[Region] <> "US"
                            && Table3[Region] <> "UK"
                    )
                )
                    + CALCULATE (
                        COUNTROWS ( 'Table3' ),
                        FILTER (
                            ALLEXCEPT ( 'Table3', Table3[Date] ),
                            Table3[Item 2] = EARLIER ( 'Table3'[Item 2] )
                                && Table3[Region] <> "US"
                                && Table3[Region] <> "UK"
                        )
                    )
            )
        )
    VAR myCount2percent =
        IF ( Table3[Item 2] <> "null", DIVIDE ( 1 / myCount2, 1 ), 0 )
    RETURN
        myCount2percent + myCount1percent

     

    Best regards,

    Yuliana Gu