Combine seperate lookupsets - find max(), count()?
Hello, my knowledge of SSRS is intermediate. Enough to have a plan. But I need just a little assistance.
Here are the functions.
here are my three lookupsets:
-LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value, “AccountActivities”)
-LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value, “AccountContactActivities”)
-LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value, “AccountOpportunityActivities”)
1) How could I find the 'Max()' of all three of these datasets. The single highest number.
2) How could I find the 'COUNT()' of all three of these datasets. The total number of rows.
If they can be done separately and then added together using variables, that is an acceptable solution. Still, I'm just learning syntax here.
THanks
Hi ebs_software,
According to your description, you used three lookupset function to retrieve data from other dataset, now you want to select max value and count of values of all three datasets.
I tested the issue in my local machine, we could not select sum and max value returned by lookupset function directly. To workaround this issue, we need to use custom code. For detail information, please refer to the following document:
1. Right-click outside of the report, click Report Properties.
2. Click Code in left pane, type the code like below:
Public Function AggLookup(ByVal choice as String, ByVal items as Object)
If items is Nothing then
Return Nothing
End If
Dim current as Decimal
Dim sum as Decimal
Dim count as Integer
Dim min as Decimal
Dim max as Decimal
Dim err as String
current = 0
sum = 0
count = 0
err = ""
For each item as Object in items
'Calculate count
count += 1
'Check value is a number
If IsNumeric(item) then
'Set current
current = Convert.ToDecimal(item)
'Calculate sum
sum += current
'Calculate min
If min = Nothing then
min = current
End If
If Min >current then
min = current
End If
'Calculate max
If max = Nothing then
max = current
End If
If max < current then
max = current
End If
'Return NaN if value is not a number
Else
err = "NaN"
End If
Next
'Select and set output based on the user choice or choice passed by function
If err = "NaN" then
If choice = "count" then
Return count
Else
Return err
End If
Else
Select Case choice
Case "sum"
Return sum
Case "count"
Return count
Case "min"
Return min
Case "max"
Return max
Case "avg"
'Calculate the average avoiding divide by zero errors
If count > 0 then
Return sum / count
Else
Return 0
End If
End Select
End If
End Function
3. Right-click handle of the column you want to count values returned by lookupset function, click Expression.
4. In Expression text box, type the expression like below:
=LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountActivities").Length + LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountContactActivities").Length + LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountOpportunityActivities").Length
5. Right-click handle of the column you want to calculate total of values returned by lookupset function, click Expression.
6. In Expression text box, type the expression like below:
=Code.AggLookup("sum",LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountActivities"))
7. Right-click handle of the column you want to select max value returned by lookupset function, click Expression.
8. In Expression text box, type the expression like below:
=Code.AggLookup("max",LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountActivities"))
The following screenshot is for your reference:
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here.
Wendy Fu
TechNet Community Support
Similar Messages
-
[SOLVED] makepkg gives "grep: invalid max count"
[thiderman@justitia dunst-git]$ makepkg
==> Making package: dunst-git 1.0.0.554.92cda43-1 (Sat Dec 28 16:52:48 CET 2013)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Updating dunst git repo...
Fetching origin
==> Validating source files with md5sums...
dunst ... Skipped
==> Validating source files with sha256sums...
dunst ... Skipped
==> Extracting sources...
-> Creating working copy of dunst git repo...
Cloning into 'dunst'...
done.
==> Starting pkgver()...
==> Starting prepare()...
==> Removing existing pkg/ directory...
==> Starting build()...
dunst build options:
CFLAGS = -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os -D_FORTIFY_SOURCE=2 -D_BSD_SOURCE -DVERSION="v1.0.0-30-g92cda43" -DXINERAMA -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
LDFLAGS = -Wl,-O1,--sort-common,--as-needed,-z,relro -lm -L/usr/lib/X11 -lXss -lXinerama -ldbus-1 -lX11 -lfreetype -lXext -lXft -lXss -lgio-2.0 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lxdg-basedir
CC = cc
creating config.h from config.def.h
CC -c x.c
grep: invalid max count
Makefile:31: recipe for target 'x.o' failed
make: *** [x.o] Error 2
==> ERROR: A failure occurred in build().
Aborting...
[thiderman@justitia dunst-git]$
This has happened to me for a while. I've tried building st-git and dunst-git from the AUR, and they both die with similar stacktraces. The output shown above is run in a bash with stock configuration, so no aliases or other shell trickery is going on. I've searched both source trees, but can't even find any mention of "grep" in any of them.
Googling suggested that a file with a name starting with "-m" has been found, but I can't find any of these either.
wat do?
Last edited by Daethorian (2013-12-28 17:16:25)Trilby wrote:See my edit above - but also I'd suggest removing all the "@" signs from the makefile to see what the actual command is that is failing.
It looks pretty much exactly the same:
dunst build options:
CFLAGS = -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os -D_BSD_SOURCE -DVERSION="v1.0.0-30-g92cda43" -DXINERAMA -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
LDFLAGS = -lm -L -lXss -lXinerama -ldbus-1 -lX11 -lfreetype -lXext -lXft -lXss -lgio-2.0 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lxdg-basedir
CC = cc
cc -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os -D_BSD_SOURCE -DVERSION="v1.0.0-30-g92cda43" -DXINERAMA -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
CC -c x.c
grep: invalid option -- 'g'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Makefile:31: recipe for target 'x.o' failed
make: *** [x.o] Error 2 -
Hello
Can anyone help with a max count query?
I'm trying to display houses that have had the most viewings by house type.
I need to do a count on viewing date, then display the max count value per group (type_description).
This is what I have so far:
select property.property_id, count(viewing.viewing_date), property_type.type_description
from property, viewing, property_type
where property.property_id = viewing.property_id
and (property.prop_type_id = property_type.prop_type_id)
However, I am not sure how to say I want to display the max count by type_description.
regards
Joactually, I'm afraid I don't follow the linked thread at all. I think it's perhaps because I haven't created any views. It's clearly the same assignment, but it looks like an incredibly complicated approach. I am obviously a bit dimmer than my course-mate!
is there another, simpler way of finding the max count and then grouping by type? -
How to find max(time) from table using group by
how to find max(time) from table using group by
select var max(time)
from table
into (var1, time1)
where .....
group by var.
it is fetching record which is top in table.
if u can help?
regards.No this will fetch the maximum time from teh table.
select var max(time)
from table xxxx
into (var1, time1)
where .....
group by var.
Refer this code
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH ' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT. -
What is the max. count of internal worker-threads in B1iSN 88?
Hi Experts,
We have an installation of B1iSN 88 with an ECC 6.0 and 54 SAP Business One installation. The Hardware is 8 Core multi-threads processor. 32GB Memory. Now we have a problem with the queuing of Events. What we have found is that the configuration of the internal worker-threads is set to -1(please see below for the settings). We change the settings to xcl.threads=20 and it improves the queuing. My question is what is the max. count of internal worker-threads per core? so that we can know how many worker will set and if we need to upgrade the CPU to 16 Core..
# The max. count of internal worker-threads afforded for the internal Scheduler (defaults to 1)
# The value of 0 means that there is no limit (what in general should not be set up).
# A negative value means the count of threads per available processor
xcl.threads=-1
Regards,
WilsonYou're very welcome.
Yes, they are very nice machines.
What a jump in performance when I swapped out the Pentium 4 620 mine had, for the PD 945, and tossed in 4 GB of memory.
That box will also run the Radeon HD 6570 with no problem too, which is what I put in mine.
The downside of that model is that there are no settings for ahci or raid.
I own or have owned every CMT since the d510 with the exception of the dc7900.
My main PC is now the 8200 Elite CMT which I installed W8.1 on.
It has an i7-2600 processor and 32 GB of memory, 1 TB SATA III hard drive.
I threw in a Radeon HD 6670 in that one.
Best Regards,
Paul -
How to find max based on 2 columns.
Hi I have a table where I have two numeric fields (date and time) )(thouse field are not date time format but numeric)
Column A represents date and column B represent time.
How would I find max value of column A and with results for A find Max for B.
example
A - - - - - - - - - -B
101010 - - - - - 202020
101011 - - - - - 202021
101012 - - - - - 202021
101010 - - - - - 202022
101012 - - - - - 202020
What I looking for is
A - - - - - - - - - - B
101012 - - - - - 202021
ThanksYou can try one of the following...
sql> select * from temp;
A B
101010 202020
101011 202021
101012 202021
101010 202022
101012 202020
1 select a,b from (
2 select a,
3 b,
4 rank () over (order by a desc, b desc) rnk
5 from temp
6* ) where rnk = 1
sql> /
A B
101012 202021
1 select a,b from (
2 select a,b from temp
3 order by a desc, b desc
4* ) where rownum = 1
sql> /
A B
101012 202021Please try to provide create table statements and insert data scripts instead of "select * from table".
It helps creating your case easier. -
Function in finding the count of ocurrances of an XML tag in j developer
Hi All,
I need to find the count of an xml tag that appears mutliple times in an xml payload.
I did not find any function in bpel doing this.I am using j developer version 11.1.1.5.0 and SOA Composite editor version 11.1.1.5.0.01.74
Is there any function in Bpel that gives as the count of occurence of an element in a payload?
Kindy suggest me on this.The below function is used inside XSLT to count the nodeset
count(inputNodeSet as node-set)
Returns the number of nodes in inputNodeSet.
Thanks,
Vijay -
How to find the count of tables going for fts(full table scan in oracle 10g
HI
how to find the count of tables going for fts(full table scan) in oracle 10g
regardsHi,
Why do you want to 'find' those tables?
Do you want to 'avoid FTS' on those tables?
You provide little information here. (Perhaps you just migrated from 9i and having problems with certain queries now?)
FTS is sometimes the fastest way to retrieve data, and sometimes an index scan is.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9422487749968
There's no 'FTS view' available, if you want to know what happens on your DB you need, like Anand already said, to trace sessions that 'worry you'. -
Selecting on a Max Count of rows
I would like some advice on the following SQL. I am trying to select the max(count(*)) of a selct count(*). (if you know what I mean??)
select district_id
from (
-- retrieve a list of districts, plus the count of employee related records
select d.district_id, count(*) CountX
from station s, division d
where s.resp_empl_num = :empID and
s.stn_status_code = 'AC' and
s.resp_div_num = d.division_code
group by d.district_id
-- match on the district with the max count #
where CountX = (
select max(count(*))
from station st, division dv
where st.resp_empl_num = :empID and
st.stn_status_code = 'AC' and
st.resp_div_num = dv.division_code
group by dv.district_id
)Try this
select district_id
from ( select district_id,
rank() over (order by count(*) desc) rn
from station s, division d
where s.resp_empl_num = :empID and
s.stn_status_code = 'AC' and
s.resp_div_num = d.division_code
group by d.district_id
) where rn=1
; -
How to find MATCH count for # in a String
Hi all,
How to find MATCH count for # in a String.
Ex: 6170#0400-0002-00#API3PT#AL#AUST#DEVE#KG#100.00#100.00#100.00#0.00##10.20
Regards,
Balavardhan.K>
balavardhan k wrote:
> I have used below syntax to find count but it is not returning the value and SY-SUBRC = 4.
>
>
> Data : l_text type string.
>
> l_text = '6170#0400-0002-00#API3PT#AL#AUST#DEVE#KG#100.00#100.00#100.00#0.00##10.20'.
>
>
> FIND ALL OCCURRENCES OF '#' IN L_TEXT MATCH COUNT mcnt .
Then it's not a # but possible a horizontal tab-sign.
Do a find on cl_abap_char_utilities=>horizontal_tab instead.
Edited by: Maen Anachronos on Nov 23, 2010 2:48 PM -
How to dynamically set Min count and Max Count values in Adobe Print Form?
How to set the Min Count and Max Count values dynamically in a Print Form?
The values when set should over ride the values set in Binding Tab.
This is all needed to print multiple Material Number labels on a single page - and the number of labels to be printed needs to be under user control - something like an Avery Address labels
Please advise.
Thanks,Here is a work around that works for me and may not be an intelligent solution .
I kept the Min Count to 1 on the subform binding properties.
Per the number of labels required, I appended the same item to the internal table so many times and passed it to the label.
it works fine for my requirement.
However - leaving out the post for a while to see if this can be done at the form level via scripting.
Thanks, -
Hi!
There are different records in PSA.
When I load to DSO I need only max value for key figure.
For example, data in PSA:
Char| KF
1| 2
1| 5
1| 3
2| 1
If I use Overwrite then result is:
1| 3
2| 1
If I use Sum then result is:
1| 10
2| 1
But I need followed reult:
1| 5
2| 1
How can I find max value for KF without using FM or Programs?Hi,
You can do this in a Start routine.
Sort the source package and copy the records with the max value to another internal table which has the same structure as your source package.
In the end of the routine, over write records in source package with the records in the internal table.
THis will help.
- Jaimin -
Avg/sum/min/max/count
Is there anyway to see the avg/sum/min/max/count when you highlight a bunch of cells? I can't figure out if iPad numbers has this function. I've read several articles that mention it.
Also, I am having trouble with some formulas, does anyone know where I might get help on that?Download *_Numbers User Guide_* and *_iWork Formulas and Functions User Guide_*
You may do that from the Help menu of the version running on a mac.
You may also download them thru :
http://support.apple.com/en_US/manuals/#iwork
You will be able to select the language used.
I don't know if there are guides specific to the ipad versions.
Yvan KOENIG (VALLAURIS, France) samedi 15 mai 2010 16:39:57 -
Hi ALL,
I need to find max date from a union result. I tried to use bellow query,
select max(last_processed) from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
I tried a SELECT from (....) as follows*
select * from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES)
This is woking perfectly. But when I tried to do max(*) i.e select max(*) from ......... gives error again.
Can some one suggest me a query to full fill my requirement please.
Thanks
Rupesh
www.orachat.comHi, Rupesh,
rupesh.sreenivas wrote:
Hi ALL,
I need to find max date from a union result. I tried to use bellow query,
select max(last_processed) from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
Anything inside quotes (including double-quotes) is case-sensitive. Everything not in quotes is capitalized before compiling. So
last_processed is the same as
"LAST_PROCESSED", but different from
"last_processed".
Don't use double-quotes. -
To find max effdt from a table
i am facing problem in finding max effdt for every employee from a table.
i have to fetch emplid's from a table according to a particular deptid but there are many entries for a employee depending on effdt.I have to fetch the entry which is of max effdt.
i wrote query like dis,is it ok?
select emplid,effdt from ps_job where deptid='10000' and effdt in (select max(effdt) from ps_job group by emplid)You need to correlate the effdt and the empid is some fashion There are a few ways to do this. The closest correct way to what you have is:
SELECT emplid, effdt
FROM ps_job o
WHERE deptid='10000' and
effdt IN (SELECT MAX(effdt) FROM ps_job i
WHERE i.emplid = o.emplid)A one-pass method, assuming you can use analytics would be:
SELECT emplid, effdt
FROM (SELECT emplid, effdt, deptid,
ROW_NUMBER() OVER(PARTITION BY emplid
ORDER BY effdt DESC) rn
FROM ps_job o)
WHERE deptid='10000' and
rn = 1John
Maybe you are looking for
-
When the new password is used, it asks also for a user name if an email account is recorded. Finally, after trying lots of user names, this one seemed to work. The website logon should not require a user name if I can get a password change by just us
-
Hi all I want vendor bank partner field available for selection while doing either FB60 or MIRO thanks Pushkaraj
-
Quick question about custom Components and Panels
Okay, so here is the situation. I created a custom component that overrides paintComponent. All this component does is draw a diagonal line. If I add this component directly to a JFrame it displays fine. The issue: I made a custom JPanel that at the
-
Redundancy for WLC 5508 7.1.103
I was trying to setup 2x WLC 5508 follow this instruction , copy config of 1 WLC to another and change the IP address. Then setup HA in global config for all AP https://supportforums.cisco.com/thread/2036661 Is there a way to confirm fail-over work w
-
I am being constantly asked to install Firefox 27.2.0 - is this legit?
My computer is a MacBook Air. I have always used Firefox. A medium sized window appears out of the blue and asks me to update to Firefox 27.2.0 ASAP. I do not know if this exists. I am now using version 27.0. I do not know if this pop up window is le