Forum Discussion

zawlh's avatar
zawlh
Icon for Helper I rankHelper I
6 years ago

Calculate % change from previous column

Hello everyone, I am new to Power BI. We used Postgres data from our chatbot system. 

So this is our chatbot result. I would like to calculate % change with line value showing how many % of user drop/jump in each day.
Can anyone help with me.
Database is like that

12 Replies

  • az38's avatar
    az38
    Icon for Community Champion rankCommunity Champion

    Hi zawlh 

    please, provide your desired output more accurace.

    what is "how many % of user drop/jump in each day" ?

    what is the total users? total by day, total cummulative or smth? How exactly calculate it? maybe you can display an example

    where is users field in your data model?

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    • zawlh's avatar
      zawlh
      Icon for Helper I rankHelper I

      az38  the number is the distinctcount of messengerID. I want percent difference from previous column(column from chart). (For eg. 38% drop from day01-begin to day01-end (assuming day01-begin is 100%). Could you solve it ?

      • az38's avatar
        az38
        Icon for Community Champion rankCommunity Champion

        zawlh 

        its still not almost clear but try to create a measure like

        Measure = 
        var _prevDayNumberStart = CALCULATE(MAX('Table'[Day Number]), FILTER(ALL('Table'), 'Table'[timestamp] < SELECTEDVALUE('Table'[timestamp]) && CONTAINSSTRING('Table'[Day Number],"begin"))
        var _prevDayTimestamp = CALCULATE(MAX('Table'[timestamp]), 'Table'[Day Number]=_prevDayNumberStart)
        
        RETURN
        DIVIDE( CALCULATE(DISTINCTCOUNT('Table'[messenger_id]), FILTER(ALL('Table'), 'Table'[timestamp] < SELECTEDVALUE('Table'[timestamp])), CALCULATE(DISTINCTCOUNT('Table'[messenger_id]), FILTER(ALL('Table'), 'Table'[timestamp] < _prevDayTimestamp) )

        not sure, it will work, need to check 

         

        do not hesitate to give a kudo to useful posts and mark solutions as solution