Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Create a measure as observation

Hi Everyone,

 

Year MonthIDOBS
2018-07A1
2018-07B2
2018-08C1
2018-09D1
2018-09E2
2018-09F3

 

I have a simple table like this and would like to create a measure (OBS) to display the record count of each month.

Could anyone tell me how to make it happen in DAX?  Thank you in advance for the support!

  • Hi Anonymous,

     

    You should first add an index column in Query Editor mode.

     

    Then, create below measure.

    OBS =
    COUNTROWS (
        FILTER (
            ALL ( 'Table2 2' ),
            'Table2 2'[Year Month] = SELECTEDVALUE ( 'Table2 2'[Year Month] )
                && 'Table2 2'[Index] <= MAX ( 'Table2 2'[Index] )
        )
    )

     

    Alternatively, you can achieve this via Power Query.

     

    Best regards,

    Yuliana Gu

1 Reply

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi Anonymous,

     

    You should first add an index column in Query Editor mode.

     

    Then, create below measure.

    OBS =
    COUNTROWS (
        FILTER (
            ALL ( 'Table2 2' ),
            'Table2 2'[Year Month] = SELECTEDVALUE ( 'Table2 2'[Year Month] )
                && 'Table2 2'[Index] <= MAX ( 'Table2 2'[Index] )
        )
    )

     

    Alternatively, you can achieve this via Power Query.

     

    Best regards,

    Yuliana Gu