Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    15

    Three Stooges query/report CHALLENGE!

    Now that I have your attention here's my predicament - I'd like to translate the output of a query which reports the "training level completion" for a group of technicians (Larry, Curly, and Moe) into a more compact format. That format is essentially a nested IF statement, and easy enough to implement if not for the 4 different skill levels. The idea is to report the highest skill level with 100% completion.



    In simple words,
    1. For each Technician (in rows), and for each Area (in columns) -
    2. Starting with Advanced skill level, is the value =100%? If so, then capture the value of “Adv” for the report
    3. Else, move to next lower skill level, Moderate, and check is value=100%? If so, then capture the value of “Mod” for the report
    4. Else, move to next lower skill level, Basic, and check is value=100%? If so, then capture the value of “Bas” for the report
    5. Else, move to next lower skill level, Trainee, and check is value=100%? If so, then capture the value of “Trn” for the report
    6. Else, capture a blank for the report


    Here's what the sample Table looks like, and what the desired Report would look like (with some cond formatting) which was simple to do in Excel.

    Thanks in advance!

    Click image for larger version. 

Name:	2024-02-14_11-48-14-2.png 
Views:	27 
Size:	26.2 KB 
ID:	51491
    Attached Files Attached Files

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Your data is not normalised. You are currently looking at a spreadsheet, not a database table I'm afraid.
    If this data was normalised your query would be very simple by comparison.

    If I get 20 minutes I might be able to put your data into the correct tables.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    15
    Quote Originally Posted by Minty View Post
    Your data is not normalised. You are currently looking at a spreadsheet, not a database table I'm afraid.
    If this data was normalised your query would be very simple by comparison.
    If I get 20 minutes I might be able to put your data into the correct tables.
    the attached access database is a table. don't know what "normalized" means though!

  4. #4
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    15
    Quote Originally Posted by Minty View Post
    Your data is not normalised. You are currently looking at a spreadsheet, not a database table I'm afraid.
    If this data was normalised your query would be very simple by comparison.

    If I get 20 minutes I might be able to put your data into the correct tables.
    i've attached a new DB, with additional tables and a query. I hope that's what you wanted. (?)
    thanks for the quick feedback.
    Attached Files Attached Files

  5. #5
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by i-Zapp View Post
    the attached access database is a table. don't know what "normalized" means though!
    It's a table but not a data table that any database would use.
    If you need to add a skill level or another course(Area of expertise) you would have to add new fields to your table, and the entire structure would need throwing away and re-creating.

    You need at least four tables to store your data sensibly so you can query it a make a database.

    ID Technician
    1 Larry
    2 Curly
    3 Moe

    SkillLevel_ID SkillLevelDescription SkillLevel_Ordering
    1 Trainee 10
    2 Basic 20
    3 Moderate 30
    4 Advanced 40

    Course_ID CourseName CourseSetupDate
    1 Area-1 01/01/2024
    2 Area-2 01/01/2024
    3 Area-3 01/01/2024
    4 Area-4 01/01/2024
    5 Area-5 01/01/2024
    6 Area-6 01/01/2024
    7 Area-7 01/01/2024
    8 Area-8 01/01/2024
    9 Area-9 01/01/2024
    10 Area-10 01/01/2024



    You would then combine all those entities into a table that stores your results;

    CourseResult_ID Technician_ID Course_ID SkillLevel_ID CourseMark
    1 2 1 1 100.00%
    2 2 1 2 100.00%
    3 2 1 3 100.00%
    4 3 6 1 100.00%
    5 3 6 2 100.00%
    6 3 6 3 75.00%
    7 3 6 4 12.50%


    This is how a database needs to be setup to work correctly.
    Terrible sample attached, with a single form to enter the data on.
    Attached Files Attached Files
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Sorry our replies crossed in the post

    EDIT: Your second example is getting there but you need to separate out the courses and results into a meaningful structure.
    The sample I uploaded is a very stripped down example.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    15
    Quote Originally Posted by Minty View Post
    Your second example is getting there but you need to separate out the courses and results into a meaningful structure.
    The sample I uploaded is a very stripped down example.
    LOL, yeh my attachment is a MUCH simplified version of the REAL database i'm working on. Figured a simple 2D example would suffice, because at least in my case it's the final query in the development of the data that I assumed would be the basis for the Report. I suppose the subtlety I'm missing is that the underlying relationships will provide the structure to the Report?

  8. #8
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    154
    I just cheated and used Excel to unpivot that thing. Took like 10 seconds.

    let
    Source = Access.Database(File.Contents("C:\Users\User\Deskt op\ToolSheetDatabase.accdb"), [CreateNavigationProperties=true]),
    #"_MachineTbl Query" = Source{[Schema="",Item="MachineTbl Query"]}[Data],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"_MachineTbl Query", {"MachineNum"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Tool Number"}})
    in
    #"Renamed Columns"

    Then you'd just import that into Access.

  9. #9
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by i-Zapp View Post
    LOL, yeh my attachment is a MUCH simplified version of the REAL database i'm working on. Figured a simple 2D example would suffice, because at least in my case it's the final query in the development of the data that I assumed would be the basis for the Report. I suppose the subtlety I'm missing is that the underlying relationships will provide the structure to the Report?
    As is often the case simplifying things for examples doesn't help solve the problem at hand.
    If you data really is stored as per table 1 then you have a problem.

    if it's stored in a similar fashion to the example I loaded then your query is relatively simple.

    So, show us the actual data structure, assuming it's not table 1?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by madpiet View Post
    I just cheated and used Excel to unpivot that thing. Took like 10 seconds.

    let
    Source = Access.Database(File.Contents("C:\Users\User\Deskt op\ToolSheetDatabase.accdb"), [CreateNavigationProperties=true]),
    #"_MachineTbl Query" = Source{[Schema="",Item="MachineTbl Query"]}[Data],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"_MachineTbl Query", {"MachineNum"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Tool Number"}})
    in
    #"Renamed Columns"

    Then you'd just import that into Access.
    Correct thread???
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    15
    Quote Originally Posted by Minty View Post
    So, show us the actual data structure, assuming it's not table 1?
    Minty - the database in post #4, is about as elaborate as I think it needs to be... Just think of each Area's value as being entered directly into the Main table with a form. No need for a level of complication to determine HOW that number is generated/calculated.

    I think the crux of the challenge is (at a Report level) to retrieve the individual "detail-level" values that would be shown in the groups, so that you can do the IIF business (as per my original conditional IF statements). I suppose if there was a way to construct the QUERY to generate the conditional values, that'd be even more slick.

    Click image for larger version. 

Name:	2024-02-14_14-01-21.png 
Views:	25 
Size:	17.0 KB 
ID:	51500

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I'm afraid you need to read up about normalisation. Here is a good start
    https://www.accessforums.net/showthr...133#post352133

    You are storing data as field names. (your training Areas) any time you see either a repeating group (Contact1, Contact2 etc) you should in 99.9% of cases move that data to a table. Because it is data, not an entity.
    Once your data is stored as per tblCourseResults the report and query to drive it become trivial.

    As it stands you will have to manoeuvre through more hoops that a hoop shop stocks to try and get your results.
    And if anything changes in the structure (lets say skill level Very Advanced arrives or Course Area-11) the whole thing will break because you have had to kludge you way around a bad structure.
    I know it's not what you want to hear, but fix it now, or forever regret not fixing it, and all the band-aids you will waste hours on working around it.

    Excel works on wide column data. Access and any relational database normally needs Long and Thin data.

    Trust me a little bit on this, I do earn a living out of it.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by i-Zapp View Post
    the attached access database is a table. don't know what "normalized" means though!
    Read this post's links.

    https://www.accessforums.net/showthr...553#post510553
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    15
    ok one more attempt at a suitable "normalized" database...
    Attached Files Attached Files

  15. #15
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    154
    unpivot that thing.

    Yup. I unpivoted the data.


Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 11-15-2021, 03:47 PM
  2. Query Calculation challenge
    By Perfac in forum Programming
    Replies: 6
    Last Post: 01-03-2019, 10:52 AM
  3. A Security Challenge
    By isladogs in forum Sample Databases
    Replies: 4
    Last Post: 07-16-2018, 12:49 AM
  4. SQL Query challenge in Microsoft Access 2013
    By Bingfoot in forum Queries
    Replies: 5
    Last Post: 10-07-2013, 07:58 AM
  5. Anyone fancy a challenge????!!!!!!
    By gregh in forum Database Design
    Replies: 1
    Last Post: 03-14-2011, 05:36 PM

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