Calculate a sum by date

I had an Excelsheet imported in siena.
First column is Date (01/01/2011 for example) - second column is a Value. For each day i have one row and each new day i add one value. (Date and Value)
In siena i would like to calculate a sum from the beginning of the actual month until  today. And i would like to show the result in a lable.
After that i would like to add a 2nd Label an show the sum from the beginnig of actual month (1 year ago) to today (on year ago).
I would like to place both lable on the mainscreen. I tried a lot of different things but i didn't get the solution. Maybe it is very simple, but ....
Thanks for helping me soon and greetings from
Hermann

Hi Hermann123, thanks for using Siena! Below is the expression that works for me for the "need the sum of all values in the current month before today".
Let's assume that you have an Excel table named Table1. The table has 2 columns named "MyDate" and "Val", the first being Date format, the second being Number format in Excel. Let's assume you have imported the table in Siena Beta2. Given
the above assumptions, do the following:
1) Add a label
2) Set this expression for the Text property of the label:
Sum(Filter(Table1, Year(Today()) = Year(MyDate) && Month(Today()) = Month(MyDate) && Day(Today()) >= Day(MyDate)), Val)
Allow me to explain in a bit more depth
what the expression does and how I arrived to it.
Since we want to sum over multiple rows, we need to use the Sum function for a table (http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745529).
I usually start with summing *everything* in the Val column: Sum(Table1, Val)
Now it's time to narrow down the rows by filtering out the rows we don't want included. Therefore instead of Table1 I need to use something like Filter(Table1, <some_condition>)
Now let's start entering the desired condition. First we want the year to match:
Sum( Filter(Table1, Year(Today()) = Year(MyDate), Val)
Notice the <some_condition> now becomes Year(Today()) = Year(MyDate). Basically the condition is true only if the today's year matches the year in the current row of the Excel table. The Siena table-functions take care of running the condition check
for each row of the table.
Next, we want the month to match:
Sum( Filter(Table1, Year(Today()) = Year(MyDate) && Month(Today()) = Month(MyDate), Val)
To finish off, we need to incorporate the "give me only past days or today in the current month" requirement. This should be easy now:
Sum( Filter(Table1, Year(Today()) = Year(MyDate) && Month(Today()) = Month(MyDate) && Day(Today()) >= Day(MyDate), Val)
Enjoy and thanks again for using Siena!
Manski

Similar Messages

  • Need help with rule, please. Want to calculate a sum of an accountlist...

    Hello all,
    i created some accountlists for accountclasses:
    "Kontenklasse_2" is one of my accountlists and it contains all accounts wich begin with a 2 or H2.
    So i have an account called "sum_kokl2" and for this i want to calculate the sum of all accounts included in my accountlist "Kontenklasse_2" but i don´t know how.
    I hope someone can help me, many thanks in advance.
    Martin
    Edited by: user7324125 on 21.01.2010 17:06

    Hello kostasn,
    thanks for you post, i tried it but it doesn´t work.
    I am sure that my memberlists are accurate, if i use one in my data grid, i gett all correct accounts which must be in the selected accountlist.
    Perhaps the difficulty is where i want to calculate the sum. I try to describe more detailed:
    I have an entity structure for our companies, for each parent of my entity structure i need a sum of all accounts which begin with a 2. So i wrote an accountlist which include all these accounts and named it "Kontenklasse_2". I try your written code and change the necessary parts. For this accountlist i only use the custom2 dimension all other is None. I don´t use ICP. The calculated account is named sum_kokl2 but neither my base entities nor the parent entities show me any values on the account sum_kokl2. So i think somewhere i forgot an important line in my rulefile.
    Perhaps do you have another idea where is my bug? I´m happy for every help and idea.
    Many thanks for every help in advance.
    Kind regards / Best wishes
    Martin
    Btw my used Version is HFM Version 11.1.1.3, i used EPMA-Applications, the Windows-Client is installed to use the rules editor and SmartView 11 is already installed.

  • Sql ---sum of Date-time formate ......

    id time
    1 1.20
    2 2.30
    3 4.20
    4 5.30
    5 1.00
    result expected = 14:40 or (if AM/PM so result is ???)
    how can i calculate the sum of time ???
    please give me some fast tricks of handling date/time formate in oracle....

    942425 wrote:
    id time
    1 1.20
    2 2.30
    3 4.20
    4 5.30
    5 1.00
    result expected = 14:40 or (if AM/PM so result is ???)
    how can i calculate the sum of time ???
    please give me some fast tricks of handling date/time formate in oracle....Hi,
    First you post in wrong forum. Please post at PL/SQL
    Before posting there close it and mark as answered.
    if your time is number data type then you can try this
    SELECT SUM(NVL(ROUND(TRUNC(DAC_OT_HOUR)+((TO_NUMBER (SUBSTR (DAC_OT_HOUR, INSTR (DAC_OT_HOUR,'.',1,1)+1)))/60)),0))
    FROM DA_CHECKHope this helps
    Hamid
    Mark correct/helpful to help others to get right answer(s).*

  • HT201412 After ios7, My iphone4 has gone dead twice in a time frame of around two months...even though its not happening very often but a two month Old phone going dead just after a New update is not acceptable.probably ios7 still has sum bugs dat need to

    After ios7, My iphone4 has gone dead twice in a time frame of around two months...even though its not happening very often but a two month Old phone going dead just after a New update is not acceptable.probably ios7 still has sum bugs dat need to be fixed...Can this bug expected to be fixed in the next update...

    Hi 1283ar.
    Unfortunately, iOS 7 is too hard to push for the iPhone 4 and therefore has a lot of effects turned off to try to get it to run as smoothly as possible.
    However, it becomes better and better with each update coming but it's hard to do anything about the hardware on an already released phones.
    If you still have trouble or think they are too hard. My tip is, if so, to restore your iPhone 4 and make a clean setup with no iCloud backup. But all your photos in a photostream so you can access it later.

  • How to calculate the volume of data used (PI licensing limit).

    Hi,
    One of our customers has several interfases running on SAP PI. They have a license that allows them the use of PI for a quantity of Gb in message data per month (I think that's the usual way).
    They would like to know how near/far they are of their limint of data, so they would like to know how does SAP evaluate that.
    Does  anybody know wich tool(s) are used by SAP to calculate the volume of data spent in one month?. We would like to launch those tools and get this info (so we can evaluate if we can add new interfases or change the periodicity of existing ones within the limits of the current license).
    Thanks in advance for your help.
    Best Regards
    Rafa

    Hi Mark,
    I have a quick question. The links that you provided gives an idea of the way in which the volume is calculated. This is helpful.
    My question is regarding Auditing and Compliance:
    Client has bought SAP PI licence for certain GB of data per month.
    Can this report be generated automatically classified by SAP and Non SAP Systems (PI licence volume constraints are normally for data exchange for non SAP Systems)?
    Also can this data be measured at Adaptor level? How does one monitor data at Adaptor level.
    Thanks And Regards,
    Maloy

  • Customer credit memo can't auto calculate the net due date

    Hi all,
    Our user used F-27 to entry customer credit memo (PK = 11),
    [F-27|http://www.flickr.com/photos/44956360@N08/5206144134/]
    and payment term use net 60 days,
    [F-27 - screen 2|http://www.flickr.com/photos/44956360@N08/5206144210/]
    but the system display the net due date doesn't add 60 days
    [F-27 - screen 3|http://www.flickr.com/photos/44956360@N08/5206144292/]
    To use fbl1n display the net due date doesn't add 60 days
    [FBL1N|http://www.flickr.com/photos/44956360@N08/5206144344/]
    Why the system can't auto calculate the net due date when user used PK = 11, but If user use PK = 01, the system can auto calculate the net due date.
    Best regards,
    Eric

    Hi Henri,
    I found the answer, when user enter the original document number in reference field of credit memo, the system can auto calculated the net due date!
    no reference doc
    [PIC1|http://www.flickr.com/photos/44956360@N08/5208025267/]
    input reference doc
    [PIC2|http://www.flickr.com/photos/44956360@N08/5208623198/]
    Thanks for your help.
    Best regards,
    Eric

  • Calculate average for some dates

    Hi,
    I would like to calculate average for some dates. Is there any function module or any process, please provide me.
    venkat.

    Use this FM HR_HK_DIFF_BT_2_DATES
    Example:
    DATA: DATE1 type P0001-BEGDA,
              DATE2 type P0001-BEGDA,
    YEARS type P0347-SCRYY,
    MONTHS type P0347-SCRMM,
    DAYS type P0347-SCRDD.
    DATE1 = '20070331'.
    DATE2= '20070101'.
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
    EXPORTING
    DATE1 = date1
    DATE2 = date2
    OUTPUT_FORMAT = '03'
    IMPORTING
    YEARS = years
    MONTHS = months
    DAYS = days
    EXCEPTIONS
    INVALID_DATES_SPECIFIED = 1
    OTHERS = 2
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Joan

  • How to calculate days between 2 dates excluding public holidays over SAP ?

    Hi
    Have a universe over SAP data. Trying to calculate days between 2 dates. SAP holds Public Holiday data in various tables e.g  Thol and data is updated via scal. Using my univeres as a source I want to run  reports for different countries so need to have various bank holidays not just UK. In SAP function modules handle this. Has anyone designed a solution to cater for this situation in a universe ?
    Thanks in advance
    M

    Hi,
    I assume you mean SAP R/3 (ECC) when you write SAP and SAP BW.
    Are you using BW? If so, I would load the data into SAP BW, create a query using customer exit variables and build your universe on top of that...
    -J

  • I have a dynamic table that calculates the sum of all rows, no issue.  I'm struggling with pulling out a subtotal though.  I would like to have a check box in each row  that flags those rows and gives the sum of their total.  Any help would be greatly app

    I have a dynamic table that calculates the sum of all rows, no issue.  I'm struggling with pulling out a subtotal though.  I would like to have a check box in each row  that flags those rows and gives the sum of their total.  Any help would be greatly appreciated.

    Here's something I threw together rq. The script is in the change event for the checkbox in the table. (Of course, you'll have to modify it to suit the names of your fields.)
    var rows = xfa.resolveNodes("tblAmounts.Row1[*]");
    var subtotal=0;
    for (i=0; i<rows.length; i++) if (rows.item(i).cbAdd.rawValue == 1) subtotal = subtotal + rows.item(i).nfAmount.rawValue;
    nfSubtotal.rawVlaue=subtotal;

  • Urgent!!Calculate PERIOD frm Sytem Date or Load Date!!

    Hi experts,
    How to write an ABAP code in BI7 to Calculate PERIOD frm Sytem Date or Load Date???
    Pls help me ASAP...
    Edited by: SAP BI Learner on Jul 1, 2008 4:46 PM

    Please search before you post - for starting, see one thread below.
    FM to calculate fiscalyear period from current date

  • How to calculate Beginning , Current & To date opening Balances

    Hi to all
    Anybody know that How to calculate Beginning , Current & To date opening Balances in Oracle Payable
    Thanks
    Zulqarnain

    sorry igonore above one
    i don't want last day of the month
    i want last working day of the current month
    please solve this
    urgent

  • Calculate difference between two dates/times

    Hi all,
    Is there any function module to calculate difference between two dates/times which are in TIMESTAMPL format.
    I need to know how many millisconde(second,minutes, hours... )there is between these two times.
    Please, It is urgent
    Thank you all.
    Karim

    hi,
    try the following function
    CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'        
          EXPORTING                                  
               timestamp1 = timestamp1               
               timestamp2 = timestamp2               
          IMPORTING                                  
               difference = diff                     
          EXCEPTIONS                                 
               OTHERS     = 1. 
    the above function gives the difference in seconds...
    try the following  code to set the resolution to milliseconds..
    SET RUN TIME CLOCK RESOLUTION LOW
    check the thread for details:
    SET RUN TIME CLOCK RESOLUTION?
    all the best!!!
    Regards,
    Aparna

  • How to calculate the sum of cyclomatic complexity of all methods?

    I can write a rule to calculate the sum of cyclomatic complexity of all methods in my system?

    Hi Dileep,
    In your query you are not specified whether the SUM of entire internal table SALARY or break up SALARY.
    If you want just the SUM of the entire internal table SALARY.
    Try this code.
    begin of itab occurs 0,
      name(10),
      salary type i,
    end of itab.
    itab-name = 'ABC'. itab-salary = 25000.
    append itab.
    itab-name = 'CDF'. itab-salary = 50000.
    append itab.
    itab-name = 'FGH'. itab-salary = 30000.
    append itab.
    itab-name = 'LMN'. itab-salary = 35000.
    append itab.
    itab-name = 'QPR'. itab-salary = 40000.
    append itab.
    loop at itab.
      at last.                "  Note the control statement used here
        sum.
        write: 'The total salary is',itab-salary.
      endat.
    endloop.
    Regards,
    Smart

  • How to calculate days between two DATES

    How to calculate days between two DATES ?
    which is the functional module for that ?
    help me

    Hi,
    use function module : it works,
    HR_HK_DIFF_BT_2_DATES
    give output format = 03 and get the value in days.
    code is as below :
    data : DATE1 type P0001-BEGDA,
    DATE2 type P0001-BEGDA,
    YEARS type P0347-SCRYY,
    MONTHS type P0347-SCRMM,
    DAYS type P0347-SCRDD.
    date1 = '20070331'.
    date2 = '20070101'.
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
    EXPORTING
    DATE1 = date1
    DATE2 = date2
    OUTPUT_FORMAT = '03'
    IMPORTING
    YEARS = years
    MONTHS = months
    DAYS = days
    EXCEPTIONS
    INVALID_DATES_SPECIFIED = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    write : days.
    Reward points, if helpful,
    Regards,
    Sandeep Kaushik

  • TSQL query to calculate Count / Sum grouping by date on a Pivot Table

    Hi All
    I need help to group the pivot table output to group by dates and sum/count the values. I have a table like shown below.
    Date
    Student 
    Subject
    Hunt
    Marks
    18/02/2014
    Sam 
    Maths
    1
    20
    18/02/2014
    Sam 
    Maths
    1
    10
    18/02/2014
    Sam 
    Maths
    2
    30
    18/02/2014
    Luke
    Science
    1
    50
    17/02/2014
    Sam 
    Maths
    2
    50
    17/02/2014
    Luke
    Science
    2
    60
    16/02/2014
    Luke
    Science
    2
    20
    16/02/2014
    Luke
    Science
    3
    20
    I want to Group by dates and move the Hunt to columns calculating their counts and sum their marks too. Like given below.
    I wrote a pivot query like below but If i group it with dates and calculate the total marks it throws aggregate errors.
    Create Table Student_Log ([Date] datetime ,Student varchar (20), Subject varchar (20) ,Hunt int ,Marks int )
    Go
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Sam ','Maths','1','20')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Sam ','Maths','1','10')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Sam ','Maths','2','30')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Luke','Science','1','50')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-17 15:00:00.000','Sam ','Maths','2','50')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-17 15:00:00.000','Luke','Science','2','60')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-16 15:00:00.000','Luke','Science','2','20')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-16 15:00:00.000','Luke','Science','3','20')
    Go
    select * from Student_Log
    select [DATE] , [Student], [Subject] ,[1],[2],[3],[4],Total =([1]+[2]+[3]+[4])
    from
    ( select [Date], [Student], [Subject],[Hunt],[Marks] from Student_Log
    )x
    pivot
    count ( [Hunt]) for [Hunt]
    in ([1],[2],[3],[4])
    )p
    order by [Date] desc
    I have done this far only. More than this I need to enhance it with the Percentage of Hunts for each Student.
    ie like below table.
    On 18th Sam in Maths he had 2 rows on 1st hunt  and 1 row on 2nd hunt. So On the Pivot table is it possible to represent it on percentage using the Total Attempts column.
    Thanks a lot in advance.
    Its runnung in SQL 2000 Server.

    Create Table Student_Log ([Date] datetime ,Student varchar (20), Subject varchar (20) ,Hunt int ,Marks int )
    Go
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Sam ','Maths','1','20')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Sam ','Maths','1','10')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Sam ','Maths','2','30')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-18 15:00:00.000','Luke','Science','1','50')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-17 15:00:00.000','Sam ','Maths','2','50')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-17 15:00:00.000','Luke','Science','2','60')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-16 15:00:00.000','Luke','Science','2','20')
    INSERT INTO Student_Log ([Date],Student, [Subject],Hunt,Marks) VALUES('2014-02-16 15:00:00.000','Luke','Science','3','20')
    Go
    select * from Student_Log
    ;with mycte as
    Select [Date], [Student], [Subject] ,
    Count(CASE WHEN [Hunt]=1 Then Hunt End) as Hunt1,
    Count(CASE WHEN [Hunt]=2 Then Hunt End) as Hunt2,
    Count(CASE WHEN [Hunt]=3 Then Hunt End) as Hunt3,
    Count(CASE WHEN [Hunt]=4 Then Hunt End) as Hunt4,
    Count(CASE WHEN [Hunt]=1 Then Hunt End)
    +Count(CASE WHEN [Hunt]=2 Then Hunt End)
    +Count(CASE WHEN [Hunt]=3 Then Hunt End)+
    +Count(CASE WHEN [Hunt]=4 Then Hunt End) as Total,
    ISNULL(SUM(CASE WHEN [Hunt]=1 Then Marks End),0) as Mark1,
    ISNULL(SUM(CASE WHEN [Hunt]=2 Then Marks End),0) as Mark2,
    ISNULL(SUM(CASE WHEN [Hunt]=3 Then Marks End),0) as Mark3,
    ISNULL(SUM(CASE WHEN [Hunt]=4 Then Marks End),0) as Mark4
    from Student_Log
    Group By [Date], [Student], [Subject]
    Select [Date], [Student], [Subject]
    , Cast(Hunt1*1./Total*100 as int) as [1]
    , Cast(Hunt2*1./Total*100 as int) as [2]
    ,Cast(Hunt3*1./Total*100 as int) as [3]
    ,Cast(Hunt4*1./Total*100 as int) as [4]
    ,Total,Marks=( Mark1+Mark2+Mark3+Mark4)
    from mycte
    order by [Date] DESC, Student desc
    drop table Student_Log

Maybe you are looking for