SUM a COUNT function

I need to perform a summation on the results of a COUNT but I'm not sure what's the best way to do it.
Example:
TableA
CaseID (int)
FollowupCorrespondence (int) incremented
CustomerName (varchar)
/**Get the total number of followups for each customer case, and display the customer's name.*/
select sum(count(FollowupCorrespondence)), CustomerName from
tableA
group by caseID, CustomerName;
This produces an error that the functions cannot be nested. How can I get the result that I'm looking for?

This?
SQL> with tablea as (
   select 1 caseid, 'John Doe' customername, 1 followupcorrespondence from dual union all
   select 1 caseid, 'John Doe', 2 from dual union all
   select 1 caseid, 'John Doe', 3 from dual union all
   select 1 caseid, 'John Doe', 4 from dual union all
   select 2 caseid, 'Jane Doe', 1 from dual union all
   select 2 caseid, 'Jane Doe', 2 from dual union all
   select 2 caseid, 'Jane Doe', 3 from dual)
select caseid,
   count(*) over (partition by caseid) cnt_caseid,
   customername,
   followupcorrespondence
from tablea
    CASEID CNT_CASEID CUSTOMER FOLLOWUPCORRESPONDENCE
         1          4 John Doe                      1
         1          4 John Doe                      2
         1          4 John Doe                      3
         1          4 John Doe                      4
         2          3 Jane Doe                      1
         2          3 Jane Doe                      2
         2          3 Jane Doe                      3

Similar Messages

  • SSRS report with tabular model – MDX query how to get the sum and count of measure and dimension respectively.

    Hello everyone,
    I am using the following MDX query on one of my SSRS report.
    SELECT NON EMPTY { [Measures].[Days Outstanding], [Measures].[Amt] } ON COLUMNS,
    NON EMPTY { ([Customer].[Customer].[Customer Key].ALLMEMBERS) }
    HAVING [Measures].[ Days Outstanding] > 60
    DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
    FROM ( SELECT ( STRTOSET(@Location, CONSTRAINED)) ON COLUMNS
    FROM ( SELECT ( {[Date].[Fiscal Period].&[2014-06]}) ON COLUMNS
    FROM [Model]))
    Over here, the data is being filtered always for current month and for a location that is being selected by user from a report selection parameter.
    I would like to get the count of total no. of customers and sum of the amount measure.
    When I am using them in calculated members it gives incorrect values. It considers all records (ignores the sub-select statements) instead of only the records of current month and selected location.
    I also tried with EXISTING keyword in calculated members but there is not difference in output. Finally, I manage the same at SSRS level.
    Can anybody please advise what are the ways to get the required sum of [Measures].[Amt] and count of [Customer].[Customer].[Customer Key].ALLMEMBERS dimension?
    Also, does it make any difference if I manage it as SSRS level and not at MDX query level?
    Any help would be much appreciated.
    Thanks, Ankit Shah
    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html

    Can anybody please advise what are the ways to get the required sum of [Measures].[Amt] and count of [Customer].[Customer].[Customer Key].ALLMEMBERS dimension?
    Also, does it make any difference if I manage it as SSRS level and not at MDX query level?
    Hi Ankit,
    We can use SUM function and COUNT function to sum of [Measures].[Amt] and count of [Customer].[Customer].[Customer Key].ALLMEMBERS dimension. Here is a sample query for you reference.
    WITH MEMBER [measures].[SumValue] AS
    SUM([Customer].[Customer].ALLMEMBERS,[Measures].[Internet Sales Amount])
    MEMBER [measures].[CountValue] AS
    COUNT([Customer].[Customer].ALLMEMBERS)
    MEMBER [Measures].[DimensionName] AS [Customer].NAME
    SELECT {[Measures].[DimensionName],[measures].[SumValue],[measures].[CountValue]} ON 0
    FROM [Adventure Works]
    Besides, you ask that does it make any difference if I manage it as SSRS level and not at MDX query level. I don't thinks it will make much difference. The total time to generate a reporting server report (RDL) can be divided into 3 elements:Time to retrieve
    the data (TimeDataRetrieval);Time to process the report (TimeProcessing);Time to render the report (TimeRendering). If you manage it on MDX query level, then the TimeDataRetrieval might a little longer. If you manage it on report level, then the TimeProcessing
    or TimeRendering time might a little longer. You can test it on you report with following query: 
    SELECT Itempath, TimeStart,TimeDataRetrieval + TimeProcessing + TimeRendering as [total time],
    TimeDataRetrieval, TimeProcessing, TimeRendering, ByteCount, [RowCount],Source
    FROM ExecutionLog3
    WHERE itempath like '%reportname'
    Regards,
    Charlie Liao
    TechNet Community Support

  • Count function on months column gives wrong result

    Hi,
    I am on OBIEE 11.1.1.7.150120.
    I used the count function on the month column and rather than getting 12 as the answer i get 365. (i used a filter on the year column to restrict it to one year)
    How could this happen?
    Any help would be appreciated.

    I was able to get the answer as 12 on the month column in the Dim_Time using the count distinct.
    The main reason i was trying this is because i have a VALUE column in VIew_A. I am trying to sum the values of these, but when i use the sum function, the output is quite huge and wrong. I dosen't match with the monthly figures.
    For eg:
    Month
    Income Cost
    JAN
    186.96
    FEB
    309.29
    MAR
    246.82
    APR
    247.95
    998.76
    1,462.74
    MAY
    160.27
    645.60
    1,643.84
    JUN
    172.19
    693.61
    927.12
    JUL
    150.27
    605.32
    855.89
    AUG
    133.61
    483.66
    538.20
    789.22
    SEP
    144.56
    412.42
    582.34
    824.84
    OCT
    264.96
    315.66
    364.00
    631.32
    1,067.32
    1,466.22
    NOV
    240.39
    832.10
    968.32
    1,058.73
    1,638.38
    DEC
    215.81
    857.30
    869.31
    24005.34
    But if i use the sum function on the Income/cost column, the value i get is
    C_MONTH
    SUM(INCOME_COST)
    JAN
    5,795.86
    FEB
    8,660.21
    MAR
    7,651.52
    APR
    81,283.62
    MAY
    75,941.13
    JUN
    53,787.67
    JUL
    49,955.96
    AUG
    60,285.39
    SEP
    58,924.80
    OCT
    127,394.01
    NOV
    142,137.76
    DEC
    60,215.18
    This just doesn't work out. I need the answer to be 24005 by using the sum function

  • Count() function with selective criteria?

    I'm struggling with what I would expect to be a fundamental reporting concept in CR.
    Suppose I have the following EMPLOYEE table:
    u2022 EMPLOYEE.ID
    u2022 EMPLOYEE.GENDER_CODE
    u2022 EMPLOYEE.MANAGER_FLAG
    I need to generate a statistical summary report containing the following:
    u2022 Total number of Employees
    u2022 Number of Male Employees
    u2022 Number of Management Employees
    This would be easy if I could just use a Count() function in the Function Workshop which
    contained selective criteria.  For example:  Count ({EMPLOYEE.GENDER_CODE} = 'M')
    But I can't figure out how to do this without getting a CR error message.
    Record Selection doesn't work, because I need the whole data set.
    Group Selection with Summaries doesn't work, because the gender and management
    attributes are not mutually exclusive.
    One solution that seems awkward to me is to create additional SQL commands in the
    Database Expert using COUNT(*) and WHERE criteria to get the number of Males
    and number of Managers.  But I have to believe that there is a better way.  Plus this
    approach causes problems elsewhere in my report.
    Am I missing something?
    Thanks,
    Bill

    Thanks Raghavendra!
    The good news is that I was able to create a "1 or 0" formula and then sum the resulting values.
    The bad news is that I'm only able to get this to work for part of my report.
    I am joining two tables.  As an example COMPANY and EMPLOYEE.
    I can use "1 or 0" formulas on all of the employee statistics.
    But I cannot do the same for company statistics, because the number of company records being assigned a 1 is being inflated by the join between the two tables.
    I have achieved a successful result by using Running Total Fields at the end of the report.
    But I want to place these summary statistics at the begining of my report.  (Such as Total Companies in the Western Region.)
    I tried to use "COMPANY.NAME = previous(COMPANY.NAME)" logic in my function, but then I was not allowed to summarize it.
    Any ideas?
    Thanks,
    Bill

  • Rolling averages/sums for counts

    I am a new user (business objects 12 relaease 2)
    I would like to build a report in web intelligence displaying the average count of the number of records per day, where the average is calculated for a rolling window of days.
    For example a rolling daily average count of records using a 3 day window would be caluculated by:
    Summing the counts of records for the last three days and dividing by 3
    I would like to include this rolling average in a table for a specified of time period, say the last 30 days. My table would have two rows the top row would be the date and would hgave 30 entries, inbe for each of  the previous 30 days, The scond row would have the 3 day rolling average for each of the 30 days. This table format will also allow me to graph the table
    An additional problem arises becasue there are some dates that have no data. I need to include those dates, but Web Intelligence won't display them. Is there a way of displaying dates with no values in the table?

    John Berezowski,
    In response to your question: "An additional problem arises becasue there are some dates that have no data. I need to include those dates, but Web Intelligence won't display them. Is there a way of displaying dates with no values in the table?"
    The solution is to build a "backend table" in your data base that has all of the applicable dates accounted for.  Then modify your universe by linking this new table to your pre-existing table and process as a left outer join (providing that this new table is on the "left" side, otherwise a full outer join will suffice due to the manner that you've built your table).
    A technique you can apply to the other columns used in your original table would be the use of the "coalesce" function to avoid nulls and transform unjoined values to spaces (or zero or some other value for integers). 
    thanks,
    John

  • DIFFERENCE BETWEEN SUM AND COUNT IN SQL

    DIFFERENCE BETWEEN SUM AND COUNT IN SQL
    WHAT IS THE DIFFERENCE VERIFY IN DETAIL/

    21031980, I suggest you upgrade your computer sothat you can access google.
    lol.
    wtfpwnd.Google is also helpful for understanding the strange
    acronyms that show up around here lately (yes, I did
    find and understand this one). :-)Haha, sorry!
    It's the inner-gamer in me rearing its ugly head...
    :-)

  • Counter function value to multiple elements as same value in different node

    I need your help!
    I have a counter function and value of that needs to be passed to two elements of Node A and Sub Node B..
    Ex: Mapping
    Map Counter function to NodeA.Element1 and also to NodeB(subnode).Element2
    Expected Result:
    NodA.Element1 = 1
    NodeB.Element2 =1
    but I am getting the result as
    NodA.Element1 = 1
    NodeB.Element2 =2
    I understand the reason.. since the counter function is called each time..
    so my questions is how do I the expected result as mentioned--
    NodA.Element1 = 1
    NodeB.Element2 =1
    remember the XML is multiple occurence(1.. unbounded for both the nodes)
    Thanks-Gopal

    I think  I did not explain phrase it correctly..Technicallyh NodeA.Element1 value should be copied to NodeB.Element2..As long as I can generate counter to NodeA.Element1 and hold the value somewhere to copy to NodeB.Element2, that would be fine..
    the above suggestion you guys made would not work as it will create two different set of sequences.. however Index suggestion might work differently but still I might go out of sequence if I have multiple detail record for each master record..
    Here the expected output (concise)
    Record 1 - NodeA.Element1 = 1
    Record 2 -NodeB.Element2=1
    Record3- NodeA.Element1 =2
    Record4 - NodeB.Element2=2  -->two detail records
    Record5 - NodeB.Element2=2  --> two detail records
    please help

  • Count() function throws error in EQL query for metric

    Hi
    I am trying to use count function in EQL query for Metric Bar to show the number of occurrences of a record.
    When the record type doesn't exist i expect the function to return count as 0. Instead the function throws a runtime exception and the whole Metric Bar portlet fails, with error No Results Available. Even though other components in the metric bar have valid results.
    2013-02-21 13:03:51,216 WARN [MetricsBarQueryProcessor] The EQL query does not return any results.
    2013-02-21 13:03:51,216 ERROR [MetricsBarQueryProcessor] The EQL query does not return any results.
    2013-02-21 13:03:51,216 WARN [MetricsBarResultsProcessor] No statement results to process.
    The EQL query i am using is
    RETURN NUMBER_OCCURS AS SELECT COUNT(EMP_ID) AS NUMBER_OCCURS where EMP_NAME IS NOT NULL group;
    I tried using COALESCE but that doesn't help.
    Can some one please suggest a workaround to this?

    Srikanth,
    Two statements are used here because the original question was pertaining to the null set (where there are employees in the nav state but no employees that fit the special analytics criteria in the navigation state). The question/answer has nothing to do with what is in the COUNT parentheses clause as Counting a null set will always give you NULL, not 0, no matter what you put in there.
    What we're really doing, in the second part of the query, is writing a query over a set of data that is not the null set (i.e. the current navigation state). This allows the 0 value to come through in the case where the first analytics statement is evaluated over a null set of records. If there were truly no records in the navigation state, this too would return a null set and not zero.
    Hope that makes sense, feel free to respond (either on here or offline) if it's unclear.
    Regards,
    Patrick Rafferty
    http://branchbird.com

  • OBIEE: Incorrect SQL - with count function uses ORDER BY instead GROUP BY

    I made a basic report that is a client count; I want to know how many clients the company have.
    But, when I run this report, OBIEE generates a ORDER BY sentence, instead a GROUP BY. Remember that I'm using count function, that is a agregation.
    The SQL generated was:
    select 'N0' as c1,
    count(*) as c2
    from
    (select distinct T1416.CLIENT_INTER_KEY as c1
    from
    (select *
    from prd.D_SERVICE where SOURCE_SYS in ('ARBOR','PPB') and DW_SERV_ST_ID in (100000003,100000009)) T1836,
    (select *
    from prd.D_CLIENT) T1416,
    (select *
    from prd.D_CUSTOMER_ACCOUNT where SOURCE_SYS In ('ARBOR','PPB')) T1515
    where ( T1416.DW_CLIENT_ID = T1515.DW_CLIENT_ID and T1515.DW_CUST_ACCT_ID = T1836.DW_CUST_ACCT_ID and T1836.MSISDN = '917330340' )
    ) D1
    order by c1
    The error that I receive is:
    "Query Status: Query Failed: [nQSError: 16001] ODBC error state: S1000 code: -1005018 message: [Sybase][ODBC Driver][Adaptive Server Anywhere]Illegal ORDER BY item Order Item: 'N0',
    -- (opt_OrderBy.cxx 429) .
    [nQSError: 16011] ODBC error occurred while executing SQLExtendedFetch to retrieve the results of a SQL statement."
    If I substitute ORDER BY with GROUP BY and test it in Sybase, Ithe query runs without any problem.
    select 'N0' as c1,
    count(*) as c2
    from
    (select distinct T1416.CLIENT_INTER_KEY as c1
    from
    (select *
    from prd.D_SERVICE where SOURCE_SYS in ('ARBOR','PPB') and DW_SERV_ST_ID in (100000003,100000009)) T1836,
    (select *
    from prd.D_CLIENT) T1416,
    (select *
    from prd.D_CUSTOMER_ACCOUNT where SOURCE_SYS In ('ARBOR','PPB')) T1515
    where ( T1416.DW_CLIENT_ID = T1515.DW_CLIENT_ID and T1515.DW_CUST_ACCT_ID = T1836.DW_CUST_ACCT_ID and T1836.MSISDN = '917330340' )
    ) D1
    group by c1
    Do you know why OBIEE generates this SQL??? Why uses, with a aggregation function, a ORDER BY and not a GROUP BY? How can I resolve this problem???
    Regards,
    Susana Figueiredo

    Verify your repository design and make sure that you have defined count aggregate on fact column. You would also need to define the content level of each dimension in fact table.

  • Sql count function in order by clause

    Post Author: krypton
    CA Forum: Data Connectivity and SQL
    Hi Guys
    Can i ask a quick question. I am trying to retrieve data remotely from a SQL Server via crystal reports.
    Within the Database Expert I have entered a SQL query to retrive the number of (call center) support calls raised by our customers:-
    Select `Primary_Company`, COUNT(`Calls`)From  `SPRT_Issue` GROUP BY  `Primary_Company`ORDER BY  COUNT(`Calls`) desc
    The customer's column is called 'Primary Company' and the calls they raise are in the 'Calls' column. the above is a normal sql query.
    However Crystal fails to run the query and generates an error message :-
    Failed to open a rowset. Details: 420: Driver&#93; Expected lexical element not found: <identifier>
    I dont understand why it wont run. In the ORDER BY clause if i replace field 'Calls' by the field 'Primary Company' then it works.
    I think the problem is that it wont accept the count function in the order by clause. which is what i want it to do i.e display the calls in descending order by each customer.
    Could someone tell me if there is a way around it.
    Thanks
    Krypton

    Post Author: krypton
    CA Forum: Data Connectivity and SQL
    Thanks Lynn
    I tried your suggestion. But there is one probelm.
    When i sort the data in descending order using the count(calls) field, the data is returned but the customer's name appears multiple times along with their calls raised.
    E.g, if customer Mark raised multiple calls i.e. 2, 5, and 10 calls, then the report will show
    Mark   2
    Mark  5
    Mark 10
    But is there a way to aggregate all the calls for mark and show them only once:
    such as Mark   17
    Thanks

  • Distinct Count Function-how to use properly

    Hello,
    I am new to using forums & have only been using Crystal since May of 2009, so i hope i do this correctly & provide the appropriate information.  i've looked for this answer in what's been posted but cannot find it.  Some things i've read I don't really understand.  I only know how to use the functions that are in the software, i don't know how to write them myself (i think that's when people have referred to SQL code or basic syntax)
    I have CR Professional, version 11.0.0.1282 (Crystal Reports XI).
    I work at a county health dept and we have a annual medicaid cost report,  I am linking Crystal to our EMR billing module.  i have my report sorted by insurance, ie medicaid, bcbs, abw, hpm etc.  and within each ins group i have the clients ID, DOS (date of service), procedure code, charge amt, ins pmt & patient pmt.  i have totaled the charges & pmts for each group-works fine.  i even have been able to create the formula to adj out the duplicate entries in the billing module (a service was entered wrong then adjusted out then re-entered correctly-without my formula crystal was pulling both these records and adding them to total charges.)
    Where my problem lies and what my question is:  I need to count encounters, an encounter is the visit, but each visit could have 2 or more procedure codes.   So this results in multiple lines on my report for one visit, which i want for the charges to add correctly, but it makes my visit count to high. So I read about the distinct count function, of which there are three listed & i'm having a hard time understanding the differences.  What i tried is: a distinct count of the acct ID-so the same acct ID's are only counted the one time.  But some clients see us more than once per year, meaning the acct ID is the same but the DOS is different.  For this client that would be 2 visits.  But crystal is counting this as 1.
    Saying what i want to do is this:  Count as 1 when the acct ID and DOS are the same.  I've tried using the different distinct counts but when i check my formula it always has errors.  So I'm sure my lack of knowledge is what's holding me up-i fully believe crystal can do this.
    Any help would be greatly appreciated.

    I create a dummy table, set up acc_id and DOS and Charge.
    Created a running total
    Summarized acc_id
    Type of summary Count
    Evaluated using a formula
         <> previous ()
    and reset on ACC_ID
    My groups were sorted by acc_id and date
    where there were multiple visits on the same DOS my count was 0
    where the dos changed it would count accordingly.
    You may need to use two Running totals to get the complete picture.

  • Count-Function in Message Mapping

    Hey, trying to map following structures:
    message
    -m1
    --m11
    -m2
    --m22
    -m3
    --m33
    to
    message
    -m1
    --m11
    -m2
    --m22
    -m3
    --m33
    -f1
    --countItems
    The nodes m1,m2 and m3 can appear 1..unbounded. In target structure I would
    like to have the numbers of all nodes (m1,m2,m3).
    For example: In this source structure m1,m2,m3 appear only one time. In the
    field countItems I would like to have the number 3.
    I tried the count function, but it could only count the structure where I used it (in
    this case: f1).
    How can I count the above-mentioned nodes?
    thanks
    chris

    Hey,
    thanks for your answers.
    But I still couldn't understand how to do this. I open the message mapping for field f1, but the count function could only be set on an target-element, so where to set the counters for m1,m2,m3? Do I have to insert extra fields under m1..m3?
    If I do the counter would increment with every node, so if I have two times m1, in second tree of m1 a two will be insert. If I use the add function, only for these two tree the result would be three!
    @Gangisetty Vijaya Bhaskarudu
    Is this just one UDF? From where he knows, which nodes he have to count, if I have more than m1..m3, but only want to count this three?
    @ sasitharan
    same problem as mentioned above:
    this doesn't work:
    m1--count---\
    I can't use m1 as input for count! Or do I have a wrong count function?
    <b>....au damm, answered my own question. Of course. I use COUNTER and you use
    COUNT!!!!!!!!!!!! I will try this with COUNT!!</b>
    thanks
    chris

  • Count function in Administration Tool

    Hello,
    I am using Oracle BIEE 10.1.3.3 and tried using the count function in the repository so that the users have the field ready in Answers but the consistency checker returned an error stating:
    [38083] The Attribute 'No of Movements' defines a measure using an obsolete method.
    It seems that the count function has been removed in the latest version. Does anyone know please whether there is substitue repository function for it?
    Thanks a lot
    Marija

    I managed to formulate it after a lot of tries (pls see below)
    EVALUATE('count(%1) over (partition by %2)', 'CASE WHEN biwh.DIM_INVENTORY_TRANS_TYPES.TRANSACTION_TYPE_NAME LIKE "Damaged%" THEN "biwh"."DIM_PRODUCT"."PRODUCT_CODE" END', 'biwh.DIM_INVENTORY_TRANS_TYPES.TRANSACTION_TYPE_NAME')
    BUT unfortunately in Answers I am getting the following error:
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 14027] The navigator cannot handle the following request containing constants only: Evaluate( count(%1) over (partition by %2),'CASE WHEN biwh.DIM_INVENTORY_TRANS_TYPES.TRANSACTION_TYPE_NAME LIKE "Damaged%" THEN "biwh"."DIM_PRODUCT"."PRODUCT_CODE" END', 'biwh.DIM_INVENTORY_TRANS_TYPES.TRANSACTION_TYPE_NAME') as c1. (HY000)
    SQL Issued: SELECT F_INVENTORY_CONTROL."Qty of damaged products" saw_0 FROM "Inventory - Levels by Status" WHERE "DIM_INVENTORY_TRANS_TYPES"."TRANSACTION_TYPE_NAME" = 'Damaged during Handling'
    Any ideas pls??
    Marija

  • How to include the COUNT Function in business rule

    Hi all,
         I am working in oracle data quality in ODI.
         This is regarding the business rule in Data quality.
         I need to count the number of records when my status_type="A".
         But when i include the COUNT function in business rule.
         I find the following error as "*Unspecified Count Function*".
         Waiting for ur valuable reply.
         Thanks in advance,
         JayaPradha P

    Hi,
    The following is the condition I have to be used
    For eg:*Count records in DIM_SERVICE_ORDER_CODE where service_type = ‘P’*
    But when i use COUNT function.
    Im getting the error as "Unrecognised function count"
    waiting for ur valuable reply
    Thanks in advance,
    JayaPradha p

  • Why is the Tick Count function slow when used with a .dll but fine with normal lab view code?

    when using the Tick Count millisecond timer with a .dll I've written in C, I'm getting some odd timing issues.
    When I code the function I want (I'll explain it below in case it helps) in LV and run it as a subVI, feeding it the Tick count as an argument, the function runs quickly, but not quite as quickly as I would like. When I feed this same subVI just an integer constant rather than the Tick Count, it takes about the same amount of time, maybe a tiny bit more on average.
    When I bring in my function from a .dll, however, I start to run into problems. When I feed my function an integer constant, it is much faster than my subVI written in LV. When I feel my .dll the Tick Count, however, it slows down tremendously. I'm including a table with the times below:
                 |  Clock   |   Constant   |
    SubVi:   | 450ms  |  465ms       |
    .dll         | 4900ms|  75ms         |
    This is running the function 100,000 times. The function basically shifts the contents of a 2-dimensional array one place. For this function, it probably won't be a huge deal for me, but I plan on moving some of my other code out of LV and into C to speed it up, so I'd really like to figure this out.
    Thanks,
    Aaron

    Hi Aaron,
    Thanks for posting the code -- that made things a lot clearer for me. I believe I know what's going on here, and the good news is that it's easy to correct! (You shouldn't apologize for this though, as even an experienced LabVIEW programmer could run into a similar situation.) Let me explain...
    When you set your Call Library Function Node to run in the UI Thread you're telling LabVIEW that your DLL is not Thread-safe -- this means that under no circumstances should the DLL be called from more than one place at a time. Since LabVIEW itself is inherently multithreaded the way to work with a "thread-unsafe" DLL is to run it in a dedicated thread -- in this case, the UI thread. This safety comes at a price, however, as your program will have to constantly thread-swap to call the DLL and then execute block diagram code. This thread-swapping can come with a performance hit, which is what you're seeing in your application.
    The reason your "MSTick fine behavior.vi" works is that it isn't swapping threads with each iteration of the for loop -- same with the "MSTick bad behavior.vi" without the Tick Count function. When you introduce the Tick Count Function in the for loop, LabVIEW now has to swap threads every single iteration -- this is where your performance issues originate. In fact, you could reproduce the same behavior with any function (not just TIck Count) or any DLL. You could even make your "MSTick fine behavior.vi" misbehave by placing a control property node in the for loop. (Property nodes are also executed in the UI thread).
    So what's the solution? If your DLL is thread-safe, configure the call library function node to be "reentrant." You should see a pretty drastic reduction in the amount of time it takes your code to execute. In general, you can tell if your DLL is thread-safe when:
    The code is thread safe when it does not store any global data, such as global variables, files on disk, and so on.
    The code is thread safe when it does not access any hardware. In other words, the code does not contain register-level programming.
    The code is thread safe when it does not make any calls to any functions, shared libraries, or drivers that are not thread safe.
    The code is thread safe when it uses semaphores or mutexes to protect access to global resources.
    The code is thread safe when it is called by only one non-reentrant VI.
    There are also a few documents on the website that you may want to take a look at, if you want some more details on this:
    Configuring the Call Library Function Node
    An Overview of Accessing DLLs or Shared Libraries from LabVIEW
    VI Execution Speed
    I hope this helps clear-up some confusion -- best of luck with your application!
    Charlie S.
    Visit ni.com/gettingstarted for step-by-step help in setting up your system

Maybe you are looking for

  • Cannot delete files from my ipod shuffle!!!

    I am new to using an ipod and i cannot delete files from my ipod, on itunes, it only shows the license agreement where the ipod files are supposed to be and no matter how many times i uninstall and reinstall itunes and agree to the license agreement

  • Cannot connect to 4G network after update to OS 10.3.1

    Have a Q10 through Sprint and after updating to OS 10.3.1 from the Blackberry site, phone will now only connect to 3G network despite availablity of 4G network. Phone used to connect to 4G network with OS 10.2,

  • Ipod nano creates an error when connected and shuts itunes down

    When I connect my ipod to the pc using the USB lead it opens itunes up, shows it is connected and then creates an error which then closes down itunes. I have tried the reset and re install etc but the same thing happens. My brothers ipod which is the

  • Is there an air print app?

    I'm trying to print from my iPad to my printer. The printer is in HP 6300 . This printer does not automatically air print is there an app that can do so?

  • What is the best way to do this? I am stuck!!

    I have a block with this, PLEASE help! I am writing a plsql package that is going to create a custom table everything is going fine EXCEPT that I don’t know what will be the best way to do this. Please point me in the right direction a function or so