Function Sum of Characters in Columns, If statements

This one is a doozy, I think. At least, I've never heard of it being needed in this way.
The Mission
To turn Hootsuite’s bulk uploader into an even better Twitter tool by checking the lengths of tweets before they are uploaded.
The Question
How can I check if the SUM of Columns B and C, Tweet and Hyperlink, respectively, exceeds 140 characters, even after Twitter shortens the Hyperlink?
NOTE: The Date/Time won't matter, as it is
only used for Scheduling purposes.
This is kind of as far as I have come. I know that there is a COUNTIF function, but I'm not sure if that will do the trick.
I would also like it to show in Column D (Cleared), if the tweet exceeds 140 characters, by how many.
A gold star to anyone who can figure this out. I will be sharing the file online for anyone who uses Hootsuite to schedule tweets, as well, so think of this as a charity event.

Here's an alternate formula, and a solution which includes your request, "I would also like it to show in Column D (Cleared), if the tweet exceeds 140 characters, by how many."
(Click image for larger, more readable version.)
=LEN(B)+MIN(LEN(C),20)-140
LEN(B) returns the number of characters in B.
MIN(LEN(C),20) returns the number of characters in the link in C if that is 20 or fewer, and returns 20 if the link will be shortened by bit.ly.
Subtracting 140 tells the number of characters still available (if negative or zero) or the number of excess characters (if positive).
The conditional format rules (applied to all cells in column D) call attention to overlong tweets by changing the fill colour to red, the text colour to yellow, and making the text bold. The second rule applies a green fill to the cell if the tweet is within the 140 character limit.
Regards,
Barry

Similar Messages

  • I use Function Sum to add a column and a new column pops up filled with 0s

    In one of my spreadsheets, every time I try to add a column of numbers using the Sum Function, a new column is added filled with 0s. What's happening? And How do I get it to just add the column?

    can't you just write an SQL script to update the new column?
    Perhaps you can use the integration_id for this? or just another column(s)..

  • Case Statement in Analytic Function SUM(n) OVER(PARTITION BY x)

    Hi Guys,
    I have the following SQL that doesn't seem to consider the When clause I am using in the case staement inside the analytic function(SUM). Could somebody let me know why? and suggest the solution?
    Select SUM(Case When (A.Flag = 'B' and B.Status != 'C') Then (NVL(A.Amount_Cr, 0) - (NVL(A.Amount_Dr,0))) Else 0 End) OVER (PARTITION BY A.Period_Year) Annual_amount
         , A.period_year
         , B.status
    , A.Flag
    from A, B, C
    where A.period_year = 2006
    and C.Account = '301010'
    --and B.STATUS != 'C'
    --and A.Flag = 'B'
    and A.Col_x = B.Col_x
    and A.Col_y = C.Col_y
    When I use this SQL, I get
    Annual_Amount Period_Year Status Flag
    5721017.5 --------- 2006 ---------- C -------- B
    5721017.5 --------- 2006 ---------- O -------- B
    5721017.5 --------- 2006 ---------- NULL ----- A
    And when I put the conditions in the where clause, I get
    Annual_Amount Period_Year Status Flag
    5721017.5 ---------- 2006 ---------- O -------- B

    Here are some scripts,
    create table testtable1 ( ColxID number(10), ColyID number(10) , Periodname varchar2(15), Flag varchar2(1), Periodyear number(15), debit number, credit number)
    insert into testtable1 values(1, 1000, 'JAN-06', 'A', 2006, 7555523.71, 7647668)
    insert into testtable1 values(2, 1001, 'FEB-06', 'B', 2006, 112710, 156047)
    insert into testtable1 values(3, 1002, 'MAR-06', 'A', 2006, 200.57, 22376.43)
    insert into testtable1 values(4, 1003, 'APR-06', 'B', 2006, 0, 53846)
    insert into testtable1 values(5, 1004, 'MAY-06', 'A', 2006, 6349227.19, 6650278.03)
    create table testtable2 ( ColxID number(10), Account number(10))
    insert into testtable2 values(1, 300100)
    insert into testtable2 values(2, 300200)
    insert into testtable2 values(3, 300300)
    insert into testtable2 values(4, 300400)
    insert into testtable2 values(5, 300500)
    create table apps.testtable3 ( ColyID number(10), Status varchar2(1))
    insert into testtable3 values(1000, 'C')
    insert into testtable3 values(1001, 'O')
    insert into testtable3 values(1002, 'C')
    My SQL:
    select t1.periodyear
         , SUM(Case When (t1.Flag = 'B' and t3.Status != 'C') Then (NVL(t1.credit, 0) - (NVL(t1.debit,0))) Else 0 End) OVER (PARTITION BY t1.PeriodYear)
         Annual_amount
         , t1.flag
         , t3.status
         , t2.account
    from testtable1 t1, testtable2 t2, testtable3 t3
    where t1.colxid = t2.colxid
    and t1.colyid = t3.colyid(+)
    --and t1.Flag = 'B' and t3.Status != 'C'
    Result:
    PeriodYear ----- AnnualAmount ----- Flag ----- Status ----- Account
    2006 ------------------ 43337 --------------- A ----------- C ---------- 300100
    2006 ------------------ 43337 --------------- B ----------- O ---------- 300200
    2006 ------------------ 43337 --------------- A ----------- C ---------- 300300
    2006 ------------------ 43337 --------------- B ------------ ----------- 300400
    2006 ------------------ 43337 --------------- A ------------ ----------- 300500
    With condition "t1.Flag = 'B' and t3.Status != 'C'" in where clause instead of in Case statement, Result is (which is desired)
    PeriodYear ----- AnnualAmount ----- Flag ----- Status ----- Account
    2006 ------------------ 43337 --------------- B ----------- O ---------- 300200

  • Analytical function SUM() OVER (PARTITION BY ) in Crosstab

    I am trying to resolve this from a very long time. I have an amount column that has to be grouped on Year, but all the other columns grouped by month. I am trying to achieve this using analytic function SUM(Case when (Condition1 and Condition2) then Sum(Amount) else 0 end) OVER ( PARTITION BY Account, Year), Where Account, Sub Account are the left axis columns. Now, column displays the values correctly, but at different rows. This is confusing.............
    For Ex: For Account 00001, there are 3 sub accounts 1000,2000,3000. For Sub account 3000, conditions 1 and 2 are satisfied, so it should display the Amount in the row corresponding to Sub account 3000, and 0 for remaining Sub Accounts. And the Total amount of all the sub accounts, which will be the same as amount for SubAccount 3000 should be displayed in the row corresponding to Account 00001.
    But I get blank rows for 1000 and 3000 Sub accounts and Amount displayed in 2000 Sub account, and blank for Account 00001 also.
    When I created the same workbook in Tabular form, the same amount is displayed for all the SubAccounts of a single Account.
    When I used this CASE statement in TOAD, I figured that this is due to the Analytic function. When I use a group by clause as shown below instead of partition by, I get the results I need.
    SELECT (Case when (Condition1 and Condition2) then Sum(Amount) else 0 end), Account, Sub Account FROM tables WHERE conditions GROUP BY Year, Account, Sub Account
    But I cannot use groupby for whole SQL of the workbook as I need the other columns with page item 'MONTH' not 'Year'.
    Could somebody please help me with this?

    Hi,
    In your tabular form do you get the correct total display against all you subaccounts and account? If this correct then you can use case to ensure that the total is displayed only for the single account.
    Once you have the correct totals working in a tabular form it is easier to re-produce what you want in a cross-tab.
    Rod West

  • Can I get multiple sums in a single column based on a "code" I place.

    After importing a file of check/debit card activity from my bank, can I 'code' the line items based on tax categories ie Utilities, Medical expenses, Auto expenses, etc. and then get sums for each based on that code I placed in a single column? That would mean multiple sums in a single column based on the code used for each tax related expense. For instance, I would put UT in the column for utilities expenses and MED in the same column if it were a medical expense. I would then want the sum for all items in that column for each item code. Is this possible or do I need to use a different approach to get this information.

    My guess is that the SUMIF function may be your friend.
    It's well described in the *iWork Formulas and Functions User Guid*e which every user may download from the Help menu.
    Yvan KOENIG (VALLAURIS, France) samedi 2 janvier 2010 21:56:39

  • Db function returning three db number columns...

    Hi ,
    Is it possible a db function to return three number columns fetched from a table...??
    If for example , there is a db function such as...:
    function x
    return number
    is
    begin
    select number_col_1 , number_col_2 , number_col_3
    into var1 , var2 , var3
    from table_a
    where <a_condition>;
    return <the_three_columns_selected>;
    end;
    so as in a select statement should write:
    select a , b , x from a_table
    many thanks ,
    Simon

    Alternatively you can return a SQL collection:
    SQL> create or replace function x (empno integer)
      2     return sys.dbms_debug_vc2coll
      3  is
      4     var1   emp.job%type;
      5     var2   emp.sal%type;
      6     var3   emp.deptno%type;
      7  begin
      8     select job, sal, deptno
      9       into var1, var2, var3
    10       from emp
    11      where empno = x.empno;
    12
    13     return sys.dbms_debug_vc2coll (var1, var2, var3);
    14  end;
    15  /
    Function created.
    SQL>
    SQL> select empno, ename, x(empno) x from emp
      2   where empno in (7788,7900)
      3  /
         EMPNO ENAME      X
          7788 SCOTT      DBMS_DEBUG_VC2COLL('ANALYST', '3000', '20')
          7900 JAMES      DBMS_DEBUG_VC2COLL('CLERK', '950', '30')

  • Unable to fetch columns; Invalid state/No Suitable Driver

    Hi!
    I'm trying to populate a combo box with data from a MySQL database (or any other database for that matter), I create a JDBC connection source, and set the following:
    URL = jdbc:mysql://localhost:3306/test
    Driver = org.mysql.jdbc.Driver (i have also tried org.gjt.mm.mysql.Driver)
    Username = anonymous
    Password = <blank>
    Next I create a NBJdbcRowSet and set:
    Command = SELECT * FROM foo
    Connection Provider = connectionSource1 (the above connection source)
    Now if I click the elipses next to Default Column Values, I get the message 'Unable to fetch columns; Invalid State'
    If I replace the NBJDBCRowSet with a NBCachedRowSet, the error becomes 'Unable to fetch columns; No Suitable Driver'.
    The database is browseable in the runtime tab, and the table exists (I can run SQL queries and get the expected results). The anonymous account exists and has access to the tables in question (the same setup is used in a few different applications, all of which work fine). Using the root account gives the same results. Using the PointBase example database gives the same results:
    Driver: com.pointbase.jdbc.jdbcUniversalDriver
    URL: jdbc:pointbase:server://localhost:9092/sample
    Details of setup:
    OS: Windows XP Pro SP2
    IDE: Sun Java Studio Enterprise 7 2004Q4
    Java version in use: 1.4.2_05 (as packaged with the studio)
    MySQL: v5.0.7-beta-nt
    Connector: MySQL Connector/J 3.0.17-ga
    PointBase: As came with Studio Enterprise
    I should mention that I can get DB connectivity in my app, I can create a comboBox and set the model to 'nBCachedRowSet1: name' and the contents of that field appears in my comboBox, however I need to create about a dozen tables and I don't relish the thought of manually creating models for each one ;)
    Any suggestions are appreciated!
    Cheers!
    Darren

    Hi Thanks for your reply.
    I've retried with PointBase and the Sample DB:
    * New project. New JFrame.
    * Create ConnectionSource, NBJdbcRowSet, ComboBox
    * Config ConnectionSource:
    - Driver: com.pointbase.jdbc.jdbcUniversalDriver
    - URL: jdbc:pointbase:server://localhost:9092/sample
    - Username/pass: as per PointBase setup
    * Config NBJdbcRowSet
    - ConnectionProvider: connectionSource1
    - Command: SELECT * FROM CUSTOMERINFO
    - Default Column Values: <open GUI>, <Fetch Columns>, "Unable to fetch columns; Invalid State"
    So this is where I get the problem, I'm not sure if i've buggered it up though, so I continue to see if I can get data:
    - Add Column: NAME
    - OK, Close
    * Config ComboBox
    - Open Model dialog
    - Select Mode: ComboBoxEditor
    - RowSet: nBJdbcRowSet1 (this throws the error again)
    - Column: NAME (entered manually, dropdown is empty)
    - OK, Close
    * Run app
    Errors!
    Seems like the GUI builder did something wrong - it generated a bunch of functions for each thing i added, like this:
    public void setJComboBox1(JComboBox val) {
    this.jComboBox1 = val;
    and the project won't compile. I figure out it should be like this:
    public void setJComboBox1(javax.swing.JComboBox val) {
    this.jComboBox1 = val;
    but the functions aren't doing anything anyway, so I delete them all. I'm starting to think my installation is borked.
    Project now compiles and runs, but there's no data, and I get:
    ClassNotFoundException: com.pointbase.jdbc.jdbcUniversalDriver
    At this point i should probably find the jar with that driver in it and mount this/add it to the classpath, but the boss has decided we'll use Borland Delphi 2005 .NET anyways, so I won't take this any further...
    Thanks for your help guys!
    Darren

  • Any method to create a SUM Total for a column whose values based on LAG?

    I have a question here, and the challenge is to explain my situation well. I am trying to develop a workbook that shows by project and month, the cost this period and the change in cost from the prior period. I want a SUM total on the Cost This Period and Cost Change From Prior Mth columns. So what I want to do looks something like this -
    Project Month Cost This Period Cost Chg from Prior Mth
    ABCDE Jan $50,000 NULL (since no preceeding row)
    ABCDE Feb $75,000 $25,000
    ABCDE Mar $60,000 -15,000
    Total $185,000 $10,000
    I do the Cost Chg from Prior Mth as a new calculation, and use the Insert Formula from Template process to use the F(x) Difference template to create my calculation. That is working just great. If you look at the underlying code for this new column, you can see the LAG function being utilized in calculating this value. I am lagging one row, as you can see from the example above.
    I can create a new total and do a SUM for the Cost This Period column and get the correct answer (the $185,000).
    The problem I am running into is that I am not getting anything when I try to sum my Cost Chg from Prior Mth column. The result is just blank (does print the total's text, but no amount).
    My thought is that the NULL row in this column was messing up the SUM from working. So I created a new calculation and said CASE WHEN Cost Chg from Prior Mth IS NULL THEN 0.00 ELSE Cost Chg from Prior Mth. So I get a new column with the same numbers except for the first row, where I now have a 0 instead of NULL. I then created a new total (SUM function) on this brand new column. Darn. Same result as for the other column. I do not get an amount.
    Has anyone else run into an issue with trying to sum up a column of numbers that are being calculated from a LAG function in Discoverer? Any suggestions on how I could get a SUM to properly calculate for this Cost Chg from Prior Mth column? Or have I run across one of those irritating "cannot handle in Discoverer" issues?
    Of course I can export the workbook run results to Excel and create the calculation in there, and that works just fine.
    John Dickey

    Hi John
    Thanks for the question and the great information. That really helped. I love these kinds of questions. They make me think :-)
    Just a thought but have you tried altering the SUM to be a CELL SUM?
    The SUM will try to evaluate the LAG over the total which would be invalid whereas, at least in theory, the CELL SUM should literally add the values.
    Best wishes
    Michael

  • Using the function SUM() in a calculated Key Figure

    Hi All,
    I need to create a calculated Key Figure and am looking for the function SUM().Can you please let me know where this is present.I have checked under the "Data Functions" and it does not seem to be present there.
    Thanks
    Aravind Pattabiraman

    Hi,
    Make use of aggragation property of the keyfigure, for summing the values of that KF.
    Regards,
    Rajkandula

  • Function module to find the columns in Internal table

    Hi Group,
    Is there any function module which displays the columns of the internal table. I guess there is one cos when we debug any program and select the "Tables" button while debugging and enter an internal table and then do a "Find" the pop up which comes up shows the internal table columns. As this functionality is in the debugger which I cannot debug hence was wondering if some one has come across any such function module. Thanks in advance.
    Regards,
    Ankur Bhandari
    [email protected]

    Hi again,
    1. In the above FM
       Pass Program as SY-REPID (U cann pass other prg name also)
    in FieldName Pass the name of the internal table
       eg. 'ITAB'
    2. This FM will give u the details of the
       internal table.
       The u can display the COMPONENTS table
       using ALV or anyother method u like.
    Regards,
    Amit M.

  • Help with this cool function: =SUMIF(Table 1::$Month, COLUMN()−1, $Cost)

    Hello,
    I am a novice with respect to spreadsheet functions and needed a a cashflow spreadsheet.  I found this one (Download Cashflow Tracker for Numbers (iWork 09).) which is perfect but the author, I suspect, has not updated his website in years.  I attempted contacting him and received no reply.
    I receive an error with the following function:
    =SUMIF(Table 1::$Month, COLUMN()−1, $Cost)
    This occurs when I enter a date in the expense or income table.  Entering the date is required to make the spreadsheet work but when I do I receive an error that a number is expected when a date is entered.
    Can anyone give me some advice?  I would really like to use this spreadsheet.
    Thanks!
    Steve

    What I have found the simplest approach has been:
    1. Cut the Summary by Category table and paste it into the Transaction sheet, giving something like this (after rearranging renaming, etc, as desired):
    2. Make sure the links between the two table are still working, make their appearance the way you like, then duplicate that sheet for the other months.  Each sheet will then have its separate set of two interconnected tables.
    3. Copy paste one of the Summary tables back to the Summary sheet, rename it as desired, and set it up with formulas referencing the tables in the monthly sheets you have set up, something like this:
    If you want your summary by month you would set up 12 columns in the main 'Summary by Category' table, with each column referencing a different sheet.  Your Budget could be a row above each Actual figure, if you like, with difference in a row below that.
    This approach keeps the formulas simple and avoids having to set up fancy SUMIFS extracting data for each month from one big Transaction table.
    SG

  • Table -- sum of rows and columns?

    I was wondering if anyone has a suggestion to how I can easily generate the sum of each row and column in a two dimensional table? This is what I've got so far:
    public class SumRowsColumns {
        public static void main (String[] args) {
         int[][] table = new int[2][3];
         // gets the values
         for (int i = 0; i < table.length;
              i++) {
             for (int j = 0; j < table.length;
              j++)
              table[i][j] = Terminal.lesInt(); // Terminal is a class that can read the terminal input
         System.out.println("\t\t\t\tSum:");
         // prints the values
         for (int i = 0; i < table.length;
         i++) {
         for (int j = 0; j < table[i].length;
              j++) {
              System.out.print("\t" + table[i][j]);
         System.out.println();
         // sum of first column
         int sumColumn = 0;
         for (int i = 0; i < table.length;
         i++) {
              sumColumn += table[i][0];
         System.out.print("\nSum:\t");
         System.out.println(sumColumn);
    Example of output:
    1
    2
    3
    4
    5
    6
                                    Sum:
            1       2       3
            4       5       6
    Sum:    5This is the output I'd like:
    1
    2
    3
    4
    5
    6
                                    Sum:
            1       2       3     6
            4       5       6     15
    Sum:    5     7     9One way of getting the sum for all the columns is to make a for-loop for each one of them, but there has to be a better way. I could apply the same hack to get the sum of the rows, but I still wouldn't know how to get the layout I want.

    After many hours of frustration I finally solved it (for-loops can be confusing, man) after I got a hint from a post in another forum: http://www.linuxquestions.org/questions/showthread.php?postid=624021#post624021
    A more logical name to the integers actually helped a lot too. And here's the final product:
    public class SumRowsColumns {
        public static void main (String[] args) {
         int[][] table = new int[2][3];
         // gets the values
         for (int row = 0; row < table.length;
              row++) {
             for (int col = 0; col < table[row].length;
               col++)
              table[row][col] = Terminal.lesInt(); // Terminal is a class that reads the terminal input
         System.out.println("\t\t\t\tSum:");
         // prints the values and sum of each row
         for (int row = 0; row < table.length;
              row++) {
             for (int col = 0; col < table[row].length;
               col++) {
              System.out.print("\t" + table[row][col]);
             int sum = 0;
             for (int col = 0; col < table[0].length;
               col++) {
              sum += table[row][col];
             System.out.println("\t" + sum);
         System.out.print("\nSum:");
         // sum of each column
         for (int col = 0; col < table[0].length; // table[0].length is the length of row 0 (the number of columns)
              col++) {
             int sum = 0;
             for (int row = 0; row < table.length; // table.length is the number of rows
               row++) {
              sum += table[row][col];
             System.out.print("\t" + sum);
         System.out.println();
    }

  • Error -90032 occurred at Error in function centref at line 5 column 8: The indexes are out of bounds for the variable you specified

    Sir, 
    i am running a matlab code in mathscript of labview but getting an error
    Error -90032 occurred at Error in function centref at line 5 column 8:  The indexes are out of bounds for the variable you specified
    this code running successfully in matlab 
    please help me in this regard
    a .vi format file is attached named as mfcc_new.vi
    Attachments:
    mfcc2.vi ‏35 KB
    mfcc_new.vi ‏111 KB

    May I see you have 6 inputs to your Mathscript Node. When you test it in Matlab I suposse that you're using some values for this inputs and everything work as expected. Then, run it in Labview using highlight execution, retaining wire values and using single stepping. Check the values which are being inserted to your Mathscript Node and ensure that they are correct. You're having an "indexes out of bounds" mistake, so it probably means that there is something  wrong with the inputs according to your expectations. You can also put the MathScript alone in another VI and insert the inputs you're expecting manually and check in the same way.
    Good luck!

  • Summing 2D Array by Columns

    Im trying to sum a 2D array by column
    Say I have 5 rows and 5 columns im trying to get the sum of all the values in the second column.
    What I have so far and have been hassling with for a while is:
    public static float sumCol(int[][] table, int rowsize, int colsize)
          int[] c = new int[colsize];
          float sum=0;
          for (int row=0; row < rowsize; row++)
            for (int col=0; col < colsize; col++)
                c[col] = table [row][col];
                sum = myMethods.sum(c);
          return sum;the sum method calculates the sum of an array
    If you can help me and just give me some pointers on how to get this, 2D arrays I think play tricks on your mind.

    I dont understand why this is giving an out of bounds
    when i call it
    public static float sumCol(int[][] table, int
    rowsize, int colsize)
    int[] c = new int[colsize];
    float sum=0;
    for (int row=0; row < rowsize; row++)
    c[row] = table [row][colsize];
    sum = myMethods.sum(c);
    return sum;
    Because number of columns is not the same as number of rows.
    I still don't understand why you are creating an array. You don't need one.
    Kaj

  • Column level stats

    Hi,
    Version 11.2.0.1
    I am asked to do column level stats on a table which is not a partartition table.
    I68-SQL> desc wmgr.re_service_hist
    Name Null? Type
    JOB_ID NOT NULL NUMBER(10)
    OPTION_ID NOT NULL NUMBER(10)
    OPTION_NAME NOT NULL VARCHAR2(50 CHAR)
    OPTION_VALUE NOT NULL VARCHAR2(4000 CHAR)
    VALUE_ORDER NOT NULL NUMBER(38)
    Usually we do table level stats.what is use of column level stats over table level stats?
    when to do column level stats?How to do it?
    Thanks

    Check these Examples please
    http://hemantoracledba.blogspot.com/2009/11/sample-sizes-table-level-and-column.html

Maybe you are looking for

  • Calculate closing balance

    Hi everyone, I've got a problem with writting a formula wich will calculate a closing balance for each account side, I mean debet and credit. In my SQL database I've got columns with: OpeningBalanceDt, OpeningBalanceCt , DtTurnover, CtTurnover, IDacc

  • HT204053 how do i add a second ipod device to my account?

    how do i add a second ipod device (ipod touch 4th gen) to my account?

  • [HA]ASA with FirePOWER Services with [HA]FireSIGHT Management Center

    Hi, My Customer orders the following SKUs in one to make these ASA with FirePOWER Services as H/A. Line Number Item Name Description Service Duration Lead Time Included Item Quantity ListPrice Extended ListPrice Discount Selling Price 1.0 ASA5515-FPW

  • Problem replacing black with a color

    I am having difficulty replacing black with a specific color (any color). I have a black and white image which is in PSD format and has RGB enabled. I have followed the instructions to replace a color via the following method: Enhance | Adjust Color

  • Custom colours for  - Content Repositry Tree in Admin Console

    Hi All , I am using weblogit 10.2 and MySql 5.0. I am usng default workflow for the content. Is it possible to display custom colours in the content repository tree, for the content based on the workflow status. and also in the tree , left side of co