Results 1 to 5 of 5
  1. #1
    ruffhi is offline Novice
    Windows 11 Access 2013 64bit
    Join Date
    Oct 2024
    Posts
    2

    Connect Excel to result of a query using iff or switch

    I have a query that calculates incremental values from cumulative values (yes - I know I am doing it twice. Assuming I can fix my connection to excel issue - which is better? IIF or SWITCH?)

    Code:
    SELECT t1.*, 
    
    IIF(t1.TriangleOPIndex = 1, 0, t1.TriangleCumValue - Nz(t2.TriangleCumValue, 0) ) AS incremental_value1, 
    
    switch (
    t1.TriangleOPIndex = 1, 0,
    true,  t1.TriangleCumValue - Nz(t2.TriangleCumValue, 0)
    ) AS incremental_value2
    
    FROM ModelTriangles AS t1 LEFT JOIN ModelTriangles AS t2 ON t1.ID = t2.ID + 1;
    It works with either IIF or SWITCH.



    However, my excel can't see this query if I include IIF or SWITCH in the query. Those queries are not in the list of items it presents when I try to form a connection to the access db. If I delete the IIF or SWITCH statement, it sees it.

    Is this me and my limited query knowledge? Excel? Access? Solar flares?

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I think there was a thread in here recently about such visibility or lack thereof. I think one suggestion was to use Excel side of things, such as Power Query. Another option (just me guessing) is to populate a table with either of those versions and link to that in Excel.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ruffhi is offline Novice
    Windows 11 Access 2013 64bit
    Join Date
    Oct 2024
    Posts
    2
    Thx for the post. I was thinking along the same lines ... either upload both cum and inc values or upload cum and then run an update query and add the inc.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    What is excel doing with the data? It may be better to have a module to populate a recordset then loop through the recordset to populate excel?

  5. #5
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Or write it to Excel and use Excel to create the cumulative total...

    DAX? Yeah, maybe not, but that's easy too... but then you're kinda stuck with DAX, and you may not want that.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 05-20-2014, 10:39 AM
  2. how can i switch this code to make a excel result?
    By richthekid in forum Import/Export Data
    Replies: 1
    Last Post: 07-25-2013, 09:16 PM
  3. Replies: 7
    Last Post: 01-11-2012, 12:24 PM
  4. result -1 in Iff statement
    By newtoAccess in forum Queries
    Replies: 10
    Last Post: 04-08-2011, 05:43 PM
  5. Replies: 5
    Last Post: 03-29-2009, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums