Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Filter report with multiple parameters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Filter report with multiple parameters

    I want to be able to filter a report by a date range and possibly one or more other parameter fields. I want the filters to be optional, and if left blank, the report will show all records. What do I need to do to accomplish this?

    1.jpg

    #2
    Re: Filter report with multiple parameters

    In the Action JavaScript to open a report you have the option of defining arguments and building a report filter. You could set the argument values to those of your criteria, and build the report filter based on the arguments.

    Comment


      #3
      Re: Filter report with multiple parameters

      I have that now Robin, but if one of the filters is not set the report does not show any records. If one of the parameters is blank, I want the report to run utilizing the other parameters.

      Comment


        #4
        Re: Filter report with multiple parameters

        If a dropdown filter is not set then you presumably want to see all the records in the report. So I think you will need to set a default value for each argument such that the default is a wildcard eg : "*". Not sure of the syntax so you may need to experiment a bit.

        Comment


          #5
          Re: Filter report with multiple parameters

          That is the purpose of my question, to save hours of experimenting. I am sure someone has done this in the past, and can point me in the right direction.

          Comment


            #6
            Re: Filter report with multiple parameters

            You can build a filter as a string. Then apply the string as the filter in the call to a report.

            How are your skills building strings with xbasic?

            http://wiki.alphasoftware.com/~alpha...nd+Expressions

            Here are some programming examples using xbasic..

            http://www.alphasoftware.com/alphafo...amming-Puzzles
            Al Buchholz
            Bookwood Systems, LTD
            Weekly QReportBuilder Webinars Thursday 1 pm CST

            Occam's Razor - KISS
            Normalize till it hurts - De-normalize till it works.
            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
            When we triage a problem it is much easier to read sample systems than to read a mind.
            "Make it as simple as possible, but not simpler."
            Albert Einstein

            http://www.iadn.com/images/media/iadn_member.png

            Comment


              #7
              Re: Filter report with multiple parameters

              Well that was like playing "Where's Waldo".....and I still never found him. I spent a lot of time searching through all that Al, but I could not find how to show all records for parameter fields which have no value.

              Comment


                #8
                Re: Filter report with multiple parameters

                Something like

                Code:
                filt_string = ""
                filt_string = filt_string+if(start_date>{} .and. end_date > {} .and. (end_date>start_date),"between(date_field,"+s_quote(start_date)+","+s_quote(end_date)+")","")
                filt_string = filt_string+if(alltrim(personnel)>""," .and. person_field = "+quote(personnel),"")
                filt_string = filt_string+if(alltrim(course)>""," .and. course_field = "+quote(course),"")
                'etcetera
                filt_string = ltrim(filt_string,".and. ")'removes leading .and. if the dates are not valid
                Last edited by Stan Mathews; 02-27-2015, 09:44 AM.
                There can be only one.

                Comment


                  #9
                  Re: Filter report with multiple parameters

                  Originally posted by Medic1196 View Post
                  Well that was like playing "Where's Waldo".....and I still never found him. I spent a lot of time searching through all that Al, but I could not find how to show all records for parameter fields which have no value.
                  Travis

                  The concept is that you build a filter string that contains the parameters that have values and ignore the ones that don't.

                  Code:
                  'so if 
                  
                  
                  p1 = "a"
                  p2 = " "
                  p3 = "x"
                  
                  
                  'the filter would be 
                  
                  'f1 = "a" .and. f3 = "x"
                  
                  'to accomplish this the code looks something like this:
                  
                  myfilter = ""
                  
                  if p1 > "" then
                  myfilter = myfilter + "f1 = "+s_quote(p1) + " "
                  end if
                  
                  if p2 > "" then
                  	if myfilter > "" then
                  	    myfilter = myfilter + ".and. "
                  	end if
                  myfilter = myfilter + " f2 = "+s_quote(p2) + " "
                  end if
                  
                  if p3 > "" then
                  	if myfilter > "" then
                  	    myfilter = myfilter + ".and. "
                  	end if
                  myfilter = myfilter + "  f3 = "+s_quote(p3) + " "
                  end if
                  
                  ui_msg_box("My filter " , myfilter)
                  Then you can use this filter to build a query.

                  The report record selection then should be set to use the currently selected records.

                  What I indicated previously will help in the filter building process.

                  Or as Stan has shown there are many ways to build a string that contains the filter and make the filter as efficient as possible.
                  Al Buchholz
                  Bookwood Systems, LTD
                  Weekly QReportBuilder Webinars Thursday 1 pm CST

                  Occam's Razor - KISS
                  Normalize till it hurts - De-normalize till it works.
                  Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                  When we triage a problem it is much easier to read sample systems than to read a mind.
                  "Make it as simple as possible, but not simpler."
                  Albert Einstein

                  http://www.iadn.com/images/media/iadn_member.png

                  Comment


                    #10
                    Re: Filter report with multiple parameters

                    I am opening a pdf report using parameters too but not all will have a parameter value. where do I put your filter?
                    my first try at this was opening a pdf report using a button that called an action javascript. does the filter go where it says 'sql filter'
                    my first try at this was this,
                    comid = :cid AND CDate >= :argStartDate AND CDate <= :argEndDate AND PID=:argPersonnel
                    OR comid = :cid AND CDate >= :argStartDate AND CDate <= :argEndDate AND :argPersonnel=""

                    which will work but each time I add a parameter I have to add another OR and then cover all the different variations.
                    there has got to be an easier way. if I have a dozen or so parameters, then my way would be ridiculous to use.

                    Comment


                      #11
                      Re: Filter report with multiple parameters

                      If you can use xbasic the general format is

                      Code:
                      query.filter = ""
                      query.order = ""
                      
                      
                      
                      :Report.SaveAs("reportnameinquotes","PDF",query.filter,query.order,"",.T.)
                      So you would use the procedure outlined above to create your own query.filter variable.

                      Probably sloppy thinking here. You won't know if the user enters an argument until the report is called so the advice is no good.

                      I think you'll have to gather the arguments via some data entry method first and then build the query.filter.
                      Last edited by Stan Mathews; 02-27-2015, 11:43 AM.
                      There can be only one.

                      Comment


                        #12
                        Re: Filter report with multiple parameters

                        Hi Travis,
                        Originally posted by Medic1196 View Post
                        I have that now Robin, but if one of the filters is not set the report does not show any records. If one of the parameters is blank, I want the report to run utilizing the other parameters.
                        What database are you using for your report?

                        The way I handle this is as follow:
                        1. I use MS SQL database, so I create a Stored Procedure with the SQL statatement I need to grab all my records. I may even use a view if I want, but AA handle Stored Procedures as the source data for reports very well.
                        2. Define the data for the report using this Stored Procedure and create a report argument for each parameter defined in the stored procedure.
                        3. Run my report from a grid or UX dialog and pass the expected parameters values as arguments.

                        The key to all this is building your Stored Procedure properly to handle empty or NULL values.
                        Edhy Rijo
                        Progytech
                        (Computer Consultants)
                        The makers of CardTracking.Net
                        www.progytech.com

                        Comment


                          #13
                          Re: Filter report with multiple parameters

                          I use MySQL and the reports utilize views. Guess I need to learn about stored procedures.

                          Comment


                            #14
                            Re: Filter report with multiple parameters

                            Are stored procedures created locally or on the server?

                            Comment


                              #15
                              Re: Filter report with multiple parameters

                              Originally posted by Medic1196 View Post
                              Are stored procedures created locally or on the server?
                              They are created in the server. Look at your MySQL help file on google.

                              I am not familiar with MySQL but here is a pseudo SQL code you can use in your Stored Procedure:
                              Code:
                              DECLARE @PersonnelPK INT = 10
                              DECLARE @ClassName VARCHAR(20) = ''
                              
                              SELECT
                              	s.*
                              FROM
                              	Students s
                              WHERE
                              	(s.PersonnelPK = @PersonnelPK [B][COLOR="#FF0000"]OR @PersonnelPK = 0[/COLOR][/B]) AND
                              	(s.ClassName = @ClassName [B][COLOR="#FF0000"]OR @ClassName = ''[/COLOR][/B])
                              The key for this SQL statement, is to test for the value of the parameters (or arguments in AA) for a default value to ignore them, I use 0 or -1 for integers or blank space '' for varchars.

                              Hope this help.
                              Edhy Rijo
                              Progytech
                              (Computer Consultants)
                              The makers of CardTracking.Net
                              www.progytech.com

                              Comment

                              Working...
                              X