Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate difference DISTINCT COUNT between rows

Hi everybody, 

 

I've matrix in this format and I'd like to calculate difference between rows. 
Meaning:
Nurture = blank
Qualify = Nurture - Qualify
Validate = Qualify - Validate 

etc.

 

Currently the values are calculated as a DISTINCTCOUNT. I tried to use EARLIER function, but it didn't work. 

 

 

Thank you for your help!

 

  • parry2k's avatar
    parry2k
    6 years ago

    Anonymous the way I see it something like this, add following measure

     

    Measure = 
    VAR __currentIndex = MAX ( Table[Index] )
    VAR __prevIndex = __currentIndex - 1
    RETURN
    CALCULATE ( <<Your Measure>>, Table[Index] = __prevIndex )

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

3 Replies

  • Anonymous you have to add an index for the funnel-like Nurture is 1, Qualify is 2, and so on . and based on this index field, you can check the value of the previous index and get the value. I hope this gives you an idea to get started.

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi parry2k ,

       

      I tried to use index, but honesly I don't know whyt it's not working. When I'll start writing EARLIER function, it says parameter is not correct type. 

      I'm using dimension tables in Matrix, so maybe that's the problem.

       

      • parry2k's avatar
        parry2k
        Super User

        Anonymous the way I see it something like this, add following measure

         

        Measure = 
        VAR __currentIndex = MAX ( Table[Index] )
        VAR __prevIndex = __currentIndex - 1
        RETURN
        CALCULATE ( <<Your Measure>>, Table[Index] = __prevIndex )

         

        I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

        Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.