Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

DAX Measure

Hi,

 

I am new to Power BI.

 

I want to right the Dax measure to get the count of customers (ID) who succeeds after their 1 attempt. For example, for id 1 the first attempt was an error & if the second or third, etc. attempt was succeeded, then I should count as one.

 

IDAttemptErrorISAttemptValid
1errorFalse
2nullTrue
1nullTrue
3errorfalse
3nulltrue

 

Regards,

praveen

2 Replies

  • You could create a measure as

    Num valid attempts = CALCULATE( COUNTROWS( 'Table' ), 'Table'[Is Valid Attempt] = TRUE() )
  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi Anonymous ,

     

    Create a index column from Power query then create a new column like below and use it as filter on your visual:-

    Column =
    VAR result =
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[ID] = EARLIER ( 'Table'[ID] )
                    && 'Table'[ISAttemptValid] = FALSE ()
                    && 'Table'[Index] < EARLIER ( 'Table'[Index] )
            )
        )
    RETURN
        IF ( result > 0, 1, 0 )

    Output:-

     

    Thanks,

    Samarth