How to take the Average of a DATEDIFF column with NULL values?

I am building an SSRS report that can display the average of a calculated datediff column in dd/hh/mm format with the following formula:
=Avg(IIF(Fields!LastCorrectedDate.Value is nothing,0, DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
LastSignDate.Value)) \(60*24) & ":" & DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
LastSignDate.Value)) mod (60*24)\60  & ":" & DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
LastSignDate.Value)) mod (60*24) - (((DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
LastSignDate.Value)) mod (60*24))\60)*60) ))
SSRS does not raise any errors with the formula and I have used the same formula for other columns without issue. I have noticed that this column includes null values which I think may be the problem. When the reports runs, it returns #ERROR on the column
but does not give a reason why.  I am using SSRS report builder with visual basic logic as opposed to embedding SQL. Any help or feedback would be greatly appreciated.

Hi No Ragrets,
According to your description, you want to calculate the average for the date time difference. Right?
In Reporting Services, Avg() function is only available for numeric values. In this scenario, the DateDiff() function to calculate the minutes difference will return a number. So we can do average calculation based on the return values first. Then we format
it as a time. We have tested this case in our local environment. Please try the following expression:
=floor(avg(DateDiff("n",Fields!StartDate.Value,Fields!EndDate.Value))) \(24*60) &":"&
floor(avg(DateDiff("n",Fields!StartDate.Value,Fields!EndDate.Value))/60 mod 24 )&":"&
floor(avg(DateDiff("n",Fields!StartDate.Value,Fields!EndDate.Value))) mod 60
The result looks like below:
If you have any question, please feel free to ask.
Best Regards,
Simon Hou

Similar Messages

  • How to select columns with null values

    HI
    In my table ‘A’ I have 10 columns and 30,000 records. I need all those columns whose value is null for all the records.
    For example in the below table column 'suffix' is null for all the records. So I want column suffix to be selected.
    Name Suffix Street
    James 1100 Washington street
    Richard 273 GEORGIA ST
    Arnold 3018 OAKHILL AVE
    MICHAEL 834 E 161ST ST
    Joseph 410 PINE AVE
    Thanks in advance

    True...
    But, i think here null needs to handle otherwise it will again throw some error like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>
    satyaki>
    satyaki>SELECT owner, table_name, column_name
      2    FROM all_tab_cols
      3   WHERE data_type NOT IN ('BLOB', 'LONG', 'CLOB')
      4         AND dbms_xmlgen.getxmltype('select count('
      5                                    || CASE
      6                                          WHEN data_type NOT IN
      7                                                     ('BLOB', 'LONG', 'CLOB')
      8                                          THEN
      9                                             column_name
    10                                          ELSE
    11                                             '1'
    12                                       END
    13                                    || ') c from '
    14                                    || owner
    15                                    || '.'
    16                                    || table_name).EXTRACT (
    17               '//text()'
    18            ).getnumberval () = 0
    19         AND table_name IN
    20                  (SELECT table_name
    21                     FROM all_tab_privs
    22                    WHERE privilege = 'SELECT' AND USER IN (grantor, grantee));
    ERROR:
    ORA-19202: Error occurred in XML processing
    ORA-24347: Warning of a NULL column in an aggregate function
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    no rows selected
    Elapsed: 00:00:04.03
    satyaki>Or,
    satyaki>
    satyaki>
    satyaki>SELECT table_name, column_name
      2    FROM user_tab_cols
      3   WHERE data_type NOT IN ('BLOB', 'LONG', 'CLOB')
      4   AND   dbms_xmlgen.getxmltype('select count('
      5                               || CASE
      6                                    WHEN data_type NOT IN ('BLOB', 'LONG', 'CLOB') THEN
      7                                          column_name
      8                                    ELSE
      9                                      '1'
    10                                  END
    11                               || ') c from '||table_name).EXTRACT('//text()').getnumberval() = 0;
    AND   dbms_xmlgen.getxmltype('select count('
    ERROR at line 4:
    ORA-19202: Error occurred in XML processing
    ORA-24347: Warning of a NULL column in an aggregate function
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    Elapsed: 00:00:02.66
    satyaki>
    satyaki>Do you have any idea to resolve this issue in this context?
    Regards.
    Satyaki De.

  • I am unable to insert the sql data into sharepoint column(with type "Person or Group") through SSIS package.

     can anyone suggest me how to insert values to sharepoint list column of datatype (person/group datatype).  Also, Does sharepoint list allows nulls as a value?
    please help.
    Thanks
    Raghavendra

    Hi Raghavendra,
    Based on my test, if we directly insert a column with people account or group name with domain\user or domain\group formats to a SharePoint list, those columns with the values would be ignored when executing the package. Other columns with Null value would
    be insert into the list. If we insert a column with numeric format, the values would change to corresponding user or group based on the site permissions in SharePoint site.
    So to fix this issue, I suggest we can select <ignore> maps to the “People or Group” column in SharePoint list. The “People or Group” column would show null value in SharePoint list. Then we can manually or use workflow feature add values in the “People
    or Group” column in SharePoint list.
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to calculate the average inventory in ABAP

    Dear All,
    Please find the below formula and this formula how to calculate the Average inventory at value.Please let me know the abap base tables and the corresponding fields.
    Formula
    Inventory Turnover = Cost of Goods Sold (COGS) / Average Inventory at value.
    Thanks
    Regards,
    Sai

    Hi Arivazhagan,
    Thanks for your quick response .
    The field MBEWH from the table is fulfill the average inventory at value.
    For Eg :I want to calculate Inventory Turnover = Cost of Goods Sold (COGS)/
    Average Inventory at value.
    so shall i take Inventory Turnover = Cost of Goods Sold (COGS)/MBEWH
    The above formula will meet my requirement to find the average inventory Turnover.
    Thanks
    Regards,
    Sai

  • How to take the cron job log in HP UX?

    Hi,
    How to take the cron job log in HP UX
    I need to run a backup and other stuff everyday. How do I check and start cron service under HP-UX UNIX operating system? How do I write cron jobs?
    A. Cron service is required to run jobs and tasks such as backup.
    You must login as the root to run following commands. Each user that is using the cron service must have a cron configuration file in the /var/spool/cron/crontab directory. Also users are permitted if their name appeared in /var/adm/cron/cron.allow file
    Task: Find out if cron is running under HP-UX
    Type the following command at a shell prompt
    # ps -ef | grep cron
    Open /etc/rc.config.d/cron file
    vi /etc/rc.config.d/cron
    Set control variable to 1 to enable cron: CRON=1
    Set control variable to 0 to disable: CRON=0
    Close and save the file. To start or stop cron you can type the following command:
    # /sbin/init.d/cron start <-- start cron
    # /sbin/init.d/cron stop <-- stop cron
    Task: HP-UX Start cron service
    If cron is not running, simply type:
    # cron
    Task: Edit / create cron jobs
    Type the following command to submit a cron job:
    # crontab -e
    List your cron file:
    # crontab -l
    Backup all your cron jobs:
    # crontab -l > ~/backup.cron.jobs
    Remove ALL cron job:
    # crontab -r
    Task: Crontab file format
    Cron file format is as follows:
    MIN HOUR DATE MONTH DAY /PATH/TO/COMMAND
    0-59 0-23 1-31 1-12 0-6 /root/scripts/backup2tape.shEasy to remember crontab file format:
    * * * * * command to be executed
    | | | | |
    | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
    | | | ------- Month (1 - 12)
    | | --------- Day of month (1 - 31)
    | ----------- Hour (0 - 23)
    ------------- Minute (0 - 59)To run /root/script/backup at 23:00, every day, enter:
    # crontab -e
    Append following
    0 23 * * * /root/script/backupRun foo job very weekday (MON-Fri) at 6am, enter:
    0 6 * * 1-5 /root/script/backupFor more information refer to cron and crontab man pages.
    Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.
    Related Other Helpful FAQs:
    What is Cron?
    Linux Start and stop the cron or crond service
    Run crontab Every 10 Minutes
    Linux / UNIX Setup and run php script as a cron job
    Stop Ubuntu / Debian Linux From Deleting /tmp Files on Boot
    Discussion on This FAQDavid Says:
    January 15th, 2008 at 12:21 am
    You might note that all files normally found in /etc/init.d, /etc/rc*.d, and others are all in /sbin in HP-UX 10.20 and up.
    Note too that your formatting is off in the description of the /etc/rc.config.d/cron file. Also, if you run /usr/bin/cron instead of /sbin/init.d/cron start, the /etc/rc.config.d/cron file is not used.
    Regards,
    Satya

    I guess it would :)
    btw, how did this piece miss from the contents pasted by the OP ?
    The doc has given all details of CRON and missed where to see the logfiles. :)
    ****Added****
    I tried man crontab in windows, i dont see it.i overlook most of the things, i would have done the same ;)
    Edited by: Bobcatalog on Oct 23, 2008 9:40 AM

  • How tom take an average of file when i have three different values

    Dear all,
    I have a file with five column,                                                              
    A    B                      C    D    E               
    2    1.23375E+17    30    31    2              
    2    2.04196E+17    0      32    2               
    2    2.31994E+17    0      33    2               
    2    2.01626E+17    30    33    2       
    2    1.79445E+17    0      34    2          
    I want to take an average of  B for D= 0 to 15,,, 16 to 30, ,, 31 to 45, 46 to 59,, anf E= 0 ,2,3,4,5,........ 23,
    for A = 2, 3, 4, 5, ......32..
    here is programme and file.
    Solved!
    Go to Solution.
    Attachments:
    iisc0040-1014.txt ‏1489 KB
    average15mins.vi ‏11 KB

    I aapreciate with you sir,
     acually my problem is differenet, i repeat it belowe.
    A    B                      C    D    E               
    2    1.23375E+17    30    0    0              
    2    2.04196E+17    0      1    0              
    2    2.31994E+17    0      2    0              
    2    2.01626E+17    30    3    0      
    2    1.79445E+17    0      4    0        
    1-Column A having the value of no of system which start from 2 to 32,,
    2- colum D having the minutes which is start from 0 to 59.
    3- colum E is hour Which varies from 0 to 23.
    now i want to keep system (Column A) constant at 2 and for 0 hour ( Column E).. and want to take the average of Values (Column B). For 0 to 15 , 16to 30 , 31 to 45, 46 to 59 ,,,minute (column C).
    Means I will have 4 value for each hour,
    means i want to put first lup where Column A is constant for 2, at the same time second lup inside the first lup Having the constant value of Column 2.  and at third lup  take the avergae of value B for each 0 to 15, 16 to 30, 31 to 45, 46 to 59,..
    hope you will help me regarding this,

  • How to take the Backup of all XI-Design Objects(Repository, Directroty,SLD)

    Deal All,
          Actually I am facing problems with XI Server.
    we have decided to reinstall the server. So, please tell me how to take the back up for all the scenarios that has been created in that. And also tell me how to take the back up for all the things.
    Then how the backups can be used in Newly initialed XI-Sys.
    Please help me.
    Thanks in advance.
    Danab

    Hi,
    In your IR and ID , you can export the Objects as TPZ files which can be reimported later.
    To expoert, select the SWCV in your IR or the Configuartion Scenario in ID and then Tools --> Export and then specify the directoy in your XI server to which export should be done and then export the same.
    Now, they will be available as TPZ files. When you need to reimport, tools --> Import and you can import.
    Regards,
    Bhavesh

  • How to take the data from sage system to sap r/3

    hi expects,
              how to take the data from sage system to sap r/3? which adapter is to be used?what is the format of data in sage system?how the scenarios will work ? please help me in solving this problem?

    hi rohit,
    the data transfer can be done by using SOAP adapter
    do chk this link
    http://www.sage.org/lists/sage-members-archive/2001/msg01718.html
    http://www.sage.org/lists/sage-members-archive/2001/msg01739.html
    thanx
    Sampath

  • How to take the screen shot of my computer page by using Labview.... is there any funtions available in Labview?

    How to take the screen shot of my computer page by using Labview.... is there any funtions available in Labview?

    Another thread about this theme.
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Please help me how to take the "Spot Color" in illustrator?

    Hi,
    Please help me how to take the "spot color in illustrator CS" using vb script (or) java script.
    Regards,
    Prabudass E.

    Prabudass,<br /><br />If you are just wanting to see if the illustrator file uses spot colors - run the Delete Unused Panel items from the default actions. then view the swatch palette in small or large List View. The color names that have a square containing a gray circle (spot) to the right of their color names are spot colors. <br /><br />The following will get the spot color name of an existing swatch named "Color1" and change it to "Nicks Swatch" and will assign the CMYK values stated.<br /><br />if (app.documents.length > 0){<br />var swatches = app.activeDocument.spots;<br />for(i=0;i<swatches.length;i++){ var currSwatch = swatches[i]; if(currSwatch.name == "Color1")<br />{currSwatch.name = "Nicks Swatch";<br />     var newColor = new CMYKColor(); <br />     newColor.cyan = 35; newColor.magenta = 0; <br />     newColor.yellow = 50; <br />     newColor.black = 0; <br />     currSwatch.color = newColor; } }}<br /><br />When this script has run the swatch palette will not immediately reflect the changes to the swatch name until you double click on a swatch and click OK or Cancel in the Edit Swatch dialog.<br /><br />I hope that I have understood your question correctly and that these responses are helpful.<br /><br />Good Luck<br /><br />Nick

  • How to find the average of table row values it should display in next row in libwindow/​CVI

    Hi,
    How to find the average of table row values it should display in next row in libwindow/CVI
    Please let me know the solution.

    There isn't a built-in function to perform calculations on thable cells. What you can do is to retrieve thable cells values and calculate the average by yourself.
    To retrieve a bunch of cells in a single instruction you can use GetTableCellRangeVals: prerequisite for this function to work correctly is that cells are all included in a Rect structure (shortly, a rectangle) and are all of the same data type. See the help for the function for some explanations and the link to an example of its usage. In Cell range parameter you can pass VAL_TABLE_ROW_RANGE (row) macro to retrieve an entire row. See here for details.
    Once you have retrieved cell values in an array, you can pass it to Mean function to calculate the average.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • I have been getting this message " no sim installed " too many times then my phone goes off , its iphone 4S , its really a problem i cant get calls or anything and im not sure how to take the SIM out then insert it again , what to do ??

    i have been getting this message " no sim installed " too many times then my phone goes off , its iphone 4S , its really a problem i cant get calls or anything and im not sure how to take the SIM out then insert it again , what to do ??

    Use the sim tool that came with your phone or a safety pin and just insert it into the hole at the side of the sim tray and push it in and then pull it out.  It is no more difficult than that and then just close it again.

  • How to take the mis reports in sap

    how to take the mis reports in sap

    Your question of this general type is discouraged here on SDN-BPX.  Please reaquaint yourself with the the [rules of engagment|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement].
    [Jeffrey Holdeman|http://wiki.sdn.sap.com/wiki/display/profile/Jeffrey+Holdeman]
    SAP Labs, LLC
    BusinessObjects Division
    Americas Customer Solutions Adoption (CSA) team

  • How to take the back up of  MPOS and planning area

    Hi Gurus ,
    i am using apo dp version 5.0 .We are trying to adding a new key kigfigures in our planning object structure and planning area .
    so,we are trying  take a back up of our Planning objects structure and planning Area .
    1.How to take the back up of MPOS and Planning area  ?
    2. How loading back the data in to the same MPOS and Planning area after adding some keyfigures to MPOS and planning area.?
    I gone  thru the www.help.sap.com but i did not understand properly .
    I would really appreciate if somebody clearly eleborate  the procedural steps .
    Thanks!
    Kriss.

    Hi Kriss,
      First let me clear you some points.
    1. MPOS always contain characteristcis only not the key figures.
    2. Planning area always contain Key figures.
    3. When you create planning area at that you have to assign MPOS & Storage bucket Profile. So Automatcially Characteristcis, Key figures & Time charcteristics realetion mentained.
    Come to your point.
    1. Before creating data source which is depend up on Planning area, you should sure that your basic structure get finalized say, MPOS, Planning area & rest configuration setting. So if you think there will be some extra key figure required after finalizing planning area then in that case you can creat some extra key figure & adding to planning area before finalizing it. So that you can use these key figure in future also.
        What ever data you want to extract from planning area you required whole data extraction process. So whenever you create data source depend up on planning area then automatcially all the info Objects( Char. key figures, time char. ) come in to data source by default. So further you have to replicate it in to APO BW & create rest data extraction process depneds up on data source. So automatcially all the info objects come in to an Info Cube & your extraction process will wrk fine.
    2. Relignment can effect on data transfer from Info Cube to Planning area becz previously your charcteristcis values are different & you had taken back with those characteristcis values, now if you did relignment then charcteristcis values are suppose to be changed, so while loading data from Info cube to Planning area your charcteristcis values will not match & data will not load for those char. values only.
        See, Data always stored in to planning area ( Live cache) against characteristcis, Key figures & time characteristcis. Data is not stored in to MPOS.
    Hope this will help you
    Regards
    Sujay

  • How long does the average iPod touch last?

    Not the battery, I mean the actuall iPod. How long does the average one last before it dies? How many hours?

    Judging from this support site, the average iPod lasts until it falls into a toilet.
    Each of my first, second, and third generation iPod Touch models are still working flawlessly. That's thousands of hours. Like Macs, they typically become functionally obsolete before any particular hardware failure ends their life.

Maybe you are looking for

  • Billing Doc Number in LBWE

    Hi, How can I include Billing doc no in 2LIS_13_VDITM DS.I have obseved that there is a field 'vbeln' from MCVBUK Communication Structure. Is it makes any sense in taking that field. Actually it is giving sales docment no also. With rgds, Anil Kumar

  • Can I upload music from iPod to iTunes? My music has disappeared from my iTunes account, but still have it on iPod.

    Music on my iTunes account has disappeared, but still have it on my older iPod; want to upload it to iTunes, but when I hook up to computer, iTunes wants to overwrite the iPod.  I fear I'll lose it all.  Any help?

  • Performa 6400/180 been hacked

    Hi, Long story short, my performa has been hacked, and I can't do much now. Floppy disk: When inserted, it asks to initialize, then after done, it says " Cannot initialize, Disk is defective!" It will read cdroms fine, but I don't know if I can use a

  • Keynote export to Quicktime still fails after upgrade to iWork 09.1

    After the update to iwork 9.1 the export to quicktime still fails with 'there is not enough disk space or there was a problem with the file Error - 108' I bought a Mac for my use at home, (got a strong one with work in mind) - keynote with embedded F

  • Problem in WSAD 5.0.0 with Oracle thin Driver

    Hi All, Can anyone help me to solve the following problem while using a batch update java.lang.NullPointerException      at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)      at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java