Forum Discussion

chris_rowley's avatar
chris_rowley
Frequent Visitor
6 years ago
Solved

Running Total using a base value from another table

So i have a table (1) currenlty with columns calculating runnings totals,

 

Booked_Running Total = calculate(
sum(All_Data[BOOKED]),
all(All_Data),
All_Data[DATE] <= EARLIER(All_Data[DATE]))

 

I then have another table (2) with 1 row that contains base values. Eseentially i would like to create 2 brand new calculated columns in table (1) that uses the base value in table (2) and performs a running total for each day adding the booked field each day to the base value

table (1)

DATAAll_ValuesCategoryCat_RefDATEBOOKEDCREATEDREBOOKEDYearWeek_CommencingBooked_Running TotalRebooked Running TotalBooked (ex.Rebooked)MONTH
1393 | 2020-08-16 00:00:00 | TRIAGE_OUTCOME_RECORDED1,393TRIAGE_OUTCOME_RECORDED4416-Aug-20000202010-Aug-2070,958,48911,338,20059,620,289August
1 | 2020-08-16 00:00:00 | PATIENT_LOCK_REMOVED1PATIENT_LOCK_REMOVED3116-Aug-20000202010-Aug-2070,958,48911,338,20059,620,289August
46 | 2020-08-16 00:00:00 | ASSESSMENT_COMPLETED46ASSESSMENT_COMPLETED2016-Aug-20000202010-Aug-2070,958,48911,338,20059,620,289August
93 | 2020-08-16 00:00:00 | ASSESSMENT_RECORDED93ASSESSMENT_RECORDED2216-Aug-20000202010-Aug-2070,958,48911,338,20059,620,289August

 

Table (2)

Cumulative Bookings (inc. Rebookings)Cumulative Bookings (ex.. Rebookings)Date
71,359,62562,643,54214 June 2015

 

i have googled and googled and i cannot find any solutions that work. hope this makes sense.

 

6 Replies

  • chris_rowley very hard to make sense out of your data table, can you paste the table with fewer columns and make sure these are not overlapping and merged together and also share what is your expected output.

     

     

  • chris_rowley , try this as column


    Booked_Running Total = calculate(
    sum(All_Data[BOOKED]),
    filter(All_Data,
    All_Data[DATE] <= EARLIER(All_Data[DATE])))

     

    And this as a measure

     

    Booked_Running Total = calculate(
    sum(All_Data[BOOKED]),
    filter(all(All_Data),
    All_Data[DATE] <= max(All_Data[DATE])))

     

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi  chris_rowley 

    If just create column as below in table(1)?

    New column 1=SUM('Table(2)'[Cumulative Bookings (inc. Rebookings) ])+'Table(1)'[Booked_Running Total]

     

    New column 2=SUM('Table(2)'[Cumulative Bookings (ex.. Rebookings) ])+'Table(1)'[Booked (ex.Rebooked)]

     

    If not your case, please share your logic and expected output.

    Please see this post regarding How to Get Your Question Answered Quickly:
    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

     

    Regards,

    Lin

  • chris_rowley's avatar
    chris_rowley
    Frequent Visitor

    hi all thank you for the assitance, unfortunatly the solutions provided didnt answer my issue which is partly my fault. Ill explain the issue a little better. in 2015 a software solution had been updated and as a result of this the data behind had changed it structure. however the figures pre the software change need to be kept hold off and one of the requirements from the data is to have a runing total per day.

     

    here is the much simpler table (1)

    Date of Booking / ReferralBookings
    15/06/1520,167
    16/06/1524,560
    17/06/1513,298
    18/06/1545,362
    19/06/1539,242
    20/06/154,211
    21/06/151,747
    22/06/1544,703

     

    Table (2) - this containts the previous running total and is needed for a base value

    Overall_TotalDate
    71,359,62514-Jun-15

     

    so essentially the calculation needs to be table (1)[bookings] + table (2)[Overall_Total] then provide a running total per day 

     

    expected result table (1)

    Date of Booking / ReferralBookingsRunning_Total_bookings_Per_day
    15/06/1520,16771,379,792
    16/06/1524,56071,404,352
    17/06/1513,29871,417,650
    18/06/1545,36271,463,012
    19/06/1539,24271,502,254
    20/06/154,21171,506,465
    21/06/151,74771,508,212
    22/06/1544,70371,552,915

     

    hopefully this clears everything up

    • v-lili6-msft's avatar
      v-lili6-msft
      Community Support

      hi  chris_rowley 

      Use this formula

      Booked_Running Total = calculate(
      sum(All_Data[Bookings]),
      FILTER(all(All_Data),
      All_Data[Date of Booking / Referral] <= EARLIER(All_Data[Date of Booking / Referral])))+SUM('Table(2)'[Overall_Total])

      and why it doesn't answer your issue

       

      please share your sample pbix file and your expected output.

       

      Regards,

      Lin