Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Filtering Formula Based on Two Fields Post Reply Post New Topic
Author Message
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Topic: Filtering Formula Based on Two Fields
    Posted: 14 Sep 2017 at 10:28am
Crystal Reports 11.5.3.417 / Windows 7

I need help with a formula to filter specific data from a report I'm using.

I have a company report for purchase orders. One of the fields on the report is 'PO.STATUS' (STRING), to which I only have 'approved' or 'close' purchase orders showing in Select Expert.

However, I also have the field 'PO.TOTALCOST' (NUMBER) on the report.

The problem I'm having is that 'PO.TOTALCOST' is bringing in all PO totals, despite my filters for 'PO.STATUS' of 'approved' or 'close'. Is there a way to only show 'PO.TOTALCOST' amounts for 'approved' or 'close' filters used in 'PO.STATUS'?

Thanks in advance.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 18 Sep 2017 at 5:12am
How are you doing the filtering?  I would seem that is you are using the Select Expert?  That should have put an AND between each conditional.
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 18 Sep 2017 at 6:06am
Thanks for the suggestion.

The Select Expert filter I'm using is this:

{PO.CONTRACTREFNUM} = "4400005536" and
{PO.STATUS} like ["APPR", "CLOSE"]

However, upon closer inspection, I changed it to this:

{PO.CONTRACTREFNUM} = "4400005536" and
{PO.STATUS} like ["APPR", "CLOSE", "REVISD"]

The problem I'm having is that if a PO is revised (REVISD), the database still keeps record of the closed (CLOSE) PO's. Is there a way to filter the records so that if a PO is revised, it eliminates the closed PO's?

For the report, the PO.TOTALCOST is bringing in all data for both REVISD and CLOSE PO's, which makes PO.TOTALCOST inaccurate.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Sep 2017 at 7:07am
are you summing PO.TOTALCOST or is it an already summed value?
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 18 Sep 2017 at 8:05am
I'm using two Running Total Fields for PO.TOTALCOST

Type of summary for both are SUM.

One is set For Each Record.

One is set for On Change Of Group.

However, the individual PO's that are revised are showing the revised (REVISD) total, and the original total (CLOSE).

Using the Running Total Field, is there a way to apply a filter so that if a PO is revised (REVISD), it eliminates the closed (CLOSE) PO amount in PO.TOTALCOST?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Sep 2017 at 9:10am
You can use an evaluate formula where you have 'for each record'
something like
PO.status = 'REVISD'


Edited by DBlank - 18 Sep 2017 at 9:11am
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 18 Sep 2017 at 9:30am
Sorry I didn't describe this well enough and I really appreciate your help with this.

Since my report is pulling in multiple PO's, there are many with a status of CLOSE that I need to show on the report.

However, there are only a few that are REVISD. With the REVISD PO's there is also a copy of it with a status of CLOSE. So with this said, every REVISD PO is pulling in double the PO.TOTALCOST (REVISD & CLOSE).

For my report, I need to pull in all PO's with a CLOSE status, except for the REVISD PO's, where I need to eliminate the CLOSE copy, and show the REVISD.

Sorry for any confusion and thanks again for your time.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2017 at 3:11am
Not knowing the actual data it is a bit difficult...
I assume first that you cannot exclude the duplicates via a stored proc or the like.
Secondly I assume that each row has the same PO # but a different PO.Status for the 'duplicates'.
You should be able to group on the PO # and create a group "flag" to indicate which PO has a revised data set. I think you are filtering by just those two statuses...
insert a summary as the max(po.status,po.po#)
any group where the max = 'REVISD' is now your grouping indicator.
IN your Running total use that in your evaluate condition.
(max(po.status,po.po#) = 'REVISD' and status = 'REVISD')
or
(max(po.status,po.po#) = 'CLOSED' and status = 'CLOSED')
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 22 Sep 2017 at 4:45am
Thanks for your suggestions. With your help I've been able to correct the issues I was having.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.