SSRS - Interactive sorting based on aggregate function
Hi,
I'm trying to add interactive sorting to one of the columns in my tablix.
The soring should be based on the LAST visit date of my child grouping. However interactive sorting is not compatible with aggregate functions apparently.
I'm using the following expression to sort on the period since the last visit:
=DateDiff(
"d"
,LAST(CDate(Fields!Visit_date.Value))
,Today()
Anyone an idea how to get this done?
Regards,
LiskieWhisky
Thanks for the input,
Qiuyun Yu: I already applied your method but my issues is that the visit dates are on de level of my
child grouping and per child multiple visit dates are possible. Since I want to complute the days since the last visit I need to take the last visit date and subtract it from today's date.
As you can see there are 2 dates. To compute the days since the last visit I take the last visit date (2015-04-17)
and subtract it from today (2015-04-27). This gives me 10 days. That's ok, no problem there.
But because I'm using the Last() function, I cannot use this expression in the Interactive sorting expression.
LucasF: You are right, but if it's possible to do this in the report I'd prefer that. But ultimately if it's necessary I'll have to do it in MDX then.
Kind regards,
LiskieWhisky
Similar Messages
-
SSRS Interactive Sort Headers Not Showing
I've written a basic report 7 columns and added interactive sort, but the sort buttons do not show in my headers when i run the report, suggestions?
Hi ,
Interactive sorting based on Textbox Properties.
So i'll suggest you to select first column Header textbox -> Textbox Proprties -> Interactive Sorting -> check enable option -> sort by column
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. -
Interactive Report based on a function returning SQL query?
Hi guys!
I'm wondering if the IR based on a function returning SQL query will be available on the final release of APEX 4.0..I can't see this functionality in EA1 and EA2 and I think it should be there..dont you think?
With regards,
PsmakRHi!
You're absolutely sure you're talking about the Interactive Report region and not about the default SQL Report region ?
With regards,
PsmakR -
Top N rows based on aggregate function
Hi,
I need to get a report in the following format
F_A F_B F_C Count_comb
100 200 300 5
100 201 300 5
100 202 301 4
100 203 111 3
Here, the Count_comb column gives the count of records which have the same (F_A + F_B + F_C) combination. The requirement is to show the Top-N combinations where the tied rows would have the same rank --that is if (100,200,300) combo and (100,201,300) combo have the same count, they should both be ranked the same.
I think this involves performing the rank() function on the count(), for which i was not able to write an SQL. Any help in this direction is appreciated.
Thanks,
<cfdoubt>
PS : Pardon the alignment--i hope you can make out what i meanHi Joseph
Hope this query satisfies your Need
Select f_a,f_b,f_c,cnt, dense_rank() over(order by cnt desc) rk
From (
select f_a,
f_b,
f_c,
count(*) cnt
from test
group by f_a,f_b,f_c
F_A F_B F_C CNT RK
100 200 300 5 1
100 201 300 5 1
100 202 301 4 2
100 203 111 3 3
Regards
Shajesh Nair
[email protected] -
Reporting Services Error after Interactive sorting and drill down in pps
Hi
i have a report that has a drill down option that shows all workgroups within a specific parent group and an interactive sorting ass well on both columns parent group & workgroup
This is displayed in pps combined with a SharePoint
---the problem is that after sorting the parent group column by name i then press the drill through icon (+) next to it hopping to see all workgroups related to each parent group
- but instead
i receive this Reporting Services Error :
The value for parameter 'SortItem' is not specified. It is either missing from the function call, or it is set to null. (rsMissingParameter) Get
Online Help
If I don't press the sorting and just drill through it works fine. the sorting itself also works fine.
any suggestions ?
Hi Hyaron,
I am unable to reproduce the issue in my test environment. How did you add the drilldown feature? Were you doing that by setting visibility of the column or of the group? Please ensure to add the drilldown functionality by set the visibility of the workgroup
from the Grouping Pane in the Report Designer.
How did you add the Interactive Sorting on the headers of the two columns? Based on the drilldown functionality, the Interactive Sorting on the second column doesn’t work. So, you can move the Interactive Sorting on the second column. When configuring the
Interactive sorting on the first column, you should set the parent group to sort, and sort by the field that the parent group groups by.
Hope this helps.
Regards,
Mike Yin
TechNet Community Support -
Can values returned by a lookupset be used for interactive sorting or a report filter?
I have a report that uses multiple stored procedures. I am using the lookupset function to return the values, then I sum the values with custom code, and have them display all into one tablix. However I can not figure out how to use interactive
sorting or a report filter with values returned by the lookupset function.
My question is:
Can you use values returned by a lookupset for interactive sorting or a report filter?
Thanks!Hi WGiff,
Based on my understanding, you want to perform interactive sorting or filter for the values which come from multiple datasets.
In Reporting Services, LookupSet()function is used to retrieve a set of values from the specified dataset. So in your scenario, we should use Lookup() function to retrieve values from specified dataset, then perform interactive sorting or filter.
As we tested in our environment, we retrieve values using Lookup() function form datasets, then sum these values with custom code. After enable interactive sorting or filter for these values, we can get expected results.
1. Add custom code below in Report Properties.
Public Shared Value as Integer=0
Public Shared Function GetValue(Item as Integer) as Integer
value= value + Item
return Item
End Function
Public Shared Function GetTotal()
Dim a as integer
a=value
value=0
return a
End Function
2. Enable Interactive Sorting.
3. Add filter within the group.
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Interactive sort order display
How can I display the order in which the user has clicked the report columns using interactive sort feature?
If I apply the interactive sort on two columns and user sorts first Column1 and then (holding Shift key) sorts Column2, then it is different sort order than when he clicks Column2 and then Column1.
Unfortunately in both these situations, the column headers look the same. You can't tell which column used clicked first (which column is first in the sort order).
I want to display the sort order before the tablix:
- sort order: Column1, Column2
or
- sort order: Column2, Column1Hi jedrekc,
According to your description, you have two columns with interactive sort in your report. Now you want to display the sequence of sorting so that you can see which column is sorted first. Right?
In Reporting Service, we don’t have any variable or function to record some kind of event like you click on interactive sort icon. That means we can’t catch this click action so that it’s impossible to display the column names based on sorting order. So
currently, your goal can’t be achieved.
However, this kind of requirement is sensible and useful. I would recommend you to submit it as a feedback to the Microsoft Connect at this link https://connect.microsoft.com/SQLServer/Feedback.
This connect site will serve as a connecting point between you and Microsoft, and ultimately the large community for you and Microsoft to interact with. Your feedback enables Microsoft to offer the best software and deliver superior services, meanwhile you
can learn more about and contribute to the exciting projects on Microsoft Connect.
If you have any question, please feel free to ask.
Best Regards,
Simon Hou (Pactera) -
Trying to create a Histogram type/object for aggregate functions
Hi,
I am trying to create an aggregate function that will return a histogram
type.
It doesn't have to be an object that is returned, I don't mind returning
a string but I would like to keep the associative array (or something
else indexed by varchar2) as a static variable between iterations.
I started out with the SecondMax example in
http://www.csis.gvsu.edu/GeneralInfo/Oracle/appdev.920/a96595/dci11agg.htm#1004821
But even seems that even a simpler aggregate function like one strCat
below (which works) has problems because I get multiple permutations for
every combination. The natural way to solve this would be to create an
associative array as a static variable as part of the Histogram (see
code below). However, apparently Oracle refuses to accept associate
arrays in this context (PLS-00355 use of pl/sql table not allowed in
this context).
If there is no easy way to do the histogram quickly can we at least get
something like strCat to work in a specific order with a "partition by
... order by clause"? It seems that even with "PARALLEL_ENABLE"
commented out strCat still calls merge for function calls like:
select hr,qtr, count(tzrwy) rwys,
noam.strCat(cnt) rwycnt,
noam.strCat(tzrwy) config,
sum(cnt) cnt, min(minscore) minscore, max(maxscore) maxscore from
ordrwys group by hr,qtr
Not only does this create duplicate entries in the query result like
"A,B,C" and "A,C,B" it seems that the order in rwycnt and config are not
always the same so a user can not match the results based on their
order.
The difference between my functions and functions like sum and the
secondMax demonstrated in the documentation is that secondMax does not
care about the order in which it gets its arguments and does not need to
maintain an ordered set in order to return the correct results. A good
example of a built in oracle function that does care about all its
arguments and probably has to maintain a similar data structure to the
one I want is the PERCTILE_DISC function. If you can find the code for
that function (or something like it) and forward a reference to me that
in itself would be very helpful.
Thanks,
K.Dingle
CREATE OR REPLACE type Histogram as object
-- TYPE Hist10 IS TABLE OF pls_integer INDEX BY varchar2(10),
-- retval hist10;
-- retval number,
retval noam.const.hist10,
static function ODCIAggregateInitialize (sctx IN OUT Histogram)
return number,
member function ODCIAggregateIterate (self IN OUT Histogram,
value IN varchar2) return number,
member function ODCIAggregateTerminate (self IN Histogram,
returnValue OUT varchar2,
flags IN number) return number,
member function ODCIAggregateMerge (self IN OUT Histogram,
ctx2 IN Histogram) return number
CREATE OR REPLACE type body Histogram is
static function ODCIAggregateInitialize(sctx IN OUT Histogram) return
number is
begin
sctx := const.Hist10();
return ODCIConst.Success;
end;
member function ODCIAggregateIterate(self IN OUT Histogram, value IN
varchar2)
return number is
begin
if self.retval.exist(value)
then self.retval(value):=self.retval(value)+1;
else self.retval(value):=1;
end if;
return ODCIConst.Success;
end;
member function ODCIAggregateTerminate(self IN Histogram,
returnValue OUT varchar2,
flags IN number)
return number is
begin
returnValue := self.retval;
return ODCIConst.Success;
end;
member function ODCIAggregateMerge(self IN OUT Histogram,
ctx2 IN Histogram) return number is
begin
i := ctx2.FIRST; -- get subscript of first element
WHILE i IS NOT NULL LOOP
if self.retval.exist(ctx2(i))
then self.retval(i):=self.retval(i)+ctx2.retval(i);
else self.retval(value):=ctx2.retval(i);
end if;
i := ctx2.NEXT(i); -- get subscript of next element
END LOOP;
return ODCIConst.Success;
end;
end;
CREATE OR REPLACE type stringCat as object
retval varchar2(16383), -- concat of all value to now varchar2, --
highest value seen so far
static function ODCIAggregateInitialize (sctx IN OUT stringCat)
return number,
member function ODCIAggregateIterate (self IN OUT stringCat,
value IN varchar2) return number,
member function ODCIAggregateTerminate (self IN stringCat,
returnValue OUT varchar2,
flags IN number) return number,
member function ODCIAggregateMerge (self IN OUT stringCat,
ctx2 IN stringCat) return number
CREATE OR REPLACE type body stringCat is
static function ODCIAggregateInitialize(sctx IN OUT stringCat) return
number is
begin
sctx := stringCat('');
return ODCIConst.Success;
end;
member function ODCIAggregateIterate(self IN OUT stringCat, value IN
varchar2)
return number is
begin
if self.retval is null
then self.retval:=value;
else self.retval:=self.retval || ',' || value;
end if;
return ODCIConst.Success;
end;
member function ODCIAggregateTerminate(self IN stringCat,
returnValue OUT varchar2,
flags IN number)
return number is
begin
returnValue := self.retval;
return ODCIConst.Success;
end;
member function ODCIAggregateMerge(self IN OUT stringCat,
ctx2 IN stringCat) return number is
begin
self.retval := self.retval || ctx2.retval;
return ODCIConst.Success;
end;
end;
CREATE OR REPLACE FUNCTION StrCat (input varchar2) RETURN varchar2
-- PARALLEL_ENABLE
AGGREGATE USING StringCat;GraphicsConfiguration is an abstract class. You would need to subclass it. From the line of code you posted, it seems like you are going about things the wrong way. What are you trying to accomplish? Shouldn't this question be posted in the Swing or AWT forum?
-
Any difference between distinct and aggregate function in sql query cost???
Hi,
I have executed many sql stmts patterns- such as:
a) using a single table
b) using two tables, using simple joins or outer joins
but i have not noticed any difference in sql stmts in cost and in execution plan....
Anyway, my colleague insists on that using aggregate function is less costly compared to
distinct....(something i have not confirmed, that's why i beleive that they are exactly the same...)
For the above reffered 1st sql pattern.. we could for example use
select distinct deptno
from emp
select count(*), deptno
from emp
group by deptno select distinct owner, object_type from all_objects
select count(*), owner, object_type from all_objects
group by owner, object_typeHave you found any difference between the two ever...????
Note: I use Ora DB 10g v2.
Thank you,
Simdistinct and aggregate function are for different uses and may give same result but if u r using aggregate function to get distinct records, it will be expensive...
ex
select distinct deptno from scott.dept;
Statistics
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
584 bytes sent via SQL*Net to client
488 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
select deptno from scott.emp group by deptno;
Statistics
307 recursive calls
0 db block gets
60 consistent gets
6 physical reads
0 redo size
576 bytes sent via SQL*Net to client
488 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
3 rows processed
Nimish Garg
Software Developer
*(Oracle & ASP.NET)*
Indiamart Intermesh Limited, Noida
To Get Free Oracle & ASP.NET Code Snippets
Follow: http://nimishgarg.blogspot.com -
Aggregate functions for internal table.
Hi Gurus,
I'm just wondering whether we can use aggregate functions for internal table. I wanted to know the max value for a particular column in my internal table. How can I achieve this easily and quickly.
Thanks,
David.sort the table on which you want the maximum value and read it. Please find below example code.
TYPES : BEGIN OF ty_mvke,
matnr TYPE mvke-matnr,
vkorg TYPE mvke-vkorg,
vtweg TYPE mvke-vtweg,
AUMNG type mvke-AUMNG,
END OF ty_mvke.
DATA : wa_mvke TYPE ty_mvke,
it_mvke TYPE STANDARD TABLE OF ty_mvke.
data : temp_AUMNG type AUMNG.
START-OF-SELECTION.
SELECT matnr vkorg vtweg AUMNG FROM mvke INTO
table it_mvke.
sort it_mvke by AUMNG.
read TABLE it_mvke into wa_mvke INDEX 1.
if sy-subrc = 0.
move wa_mvke-AUMNG to temp_AUMNG.
write : temp_AUMNG.
endif.
Thanks,
Sreekala. -
Using an Aggregate Function in a Sub-SELECT
Ok. I have this Sub-SELECT and I'd like to base my outside query based on the resyult set of my inner Sub-SELECT which contains an Aggregate function.
Is that possible???
Here's the Query...
SELECT *
FROM CUSTPRO.CPM_PND_TRAN_HDR CPMPNDTH
INNER JOIN (SELECT CPMPNDT2.ky_pnd_seq_trans,
CPMPNDT2.id_ba_esco,
CPMPNDT2.ky_ba,
CPMPNDT2.ky_enroll,
MAX(CPMPNDT2.dt_billed_by_css)
FROM CUSTPRO.CPM_PND_TRAN_HDR CPMPNDT2
WHERE CPMPNDT2.ky_pnd_seq_trans IN (6544937)
GROUP BY CPMPNDT2.ky_pnd_seq_trans,
CPMPNDT2.id_ba_esco,
CPMPNDT2.ky_ba,
CPMPNDT2.ky_enroll) DERIVE1
ON CPMPNDTH.id_ba_esco = DERIVE1.id_ba_esco
AND CPMPNDTH.ky_ba = DERIVE1.ky_ba
AND CPMPNDTH.ky_enroll = DERIVE1.ky_enroll
AND CPMPNDTH.dt_billed_by_css = ????DERIVE1.MAX(CPMPNDT2.dt_billed_by_css)???
How can I designate that last qualifier ????....
PSULionRPYou should give your aggregate function a column-alias as in:
SELECT *
FROM custpro.cpm_pnd_tran_hdr cpmpndth
INNER JOIN (SELECT cpmpndt2.ky_pnd_seq_trans,
cpmpndt2.id_ba_esco,
cpmpndt2.ky_ba,
cpmpndt2.ky_enroll,
Max(cpmpndt2.dt_billed_by_css) as XXX -- ADDED THIS.
FROM custpro.cpm_pnd_tran_hdr cpmpndt2
WHERE cpmpndt2.ky_pnd_seq_trans IN (6544937)
GROUP BY cpmpndt2.ky_pnd_seq_trans,
cpmpndt2.id_ba_esco,
cpmpndt2.ky_ba,
cpmpndt2.ky_enroll) derive1
ON cpmpndth.id_ba_esco = derive1.id_ba_esco
AND cpmpndth.ky_ba = derive1.ky_ba
AND cpmpndth.ky_enroll = derive1.ky_enroll
AND cpmpndth.dt_billed_by_css = derive1.XXX
/ -
PDF Download doesn't keep an aggregate function result
Hello,
I have an interactive report that has a sum that I created using the aggregate function. When I download to a PDF, there is no sum.
Does anyone have a solution?
Thanks,
MattHi Matt
At this time the Interactive Report Regions (IRR) don't support this functionality. I'm assuming that's what you're kicking-off the PDF generation from.
The only solution I am aware of is to set up an APEX Report & Template that contains the SUM function you require displayed in your PDF. Whilst this will deliver the result you're after, you will lose the flexibility of the IRR.
You may also want to add your comments/thoughts to this thread I started earlier.
[http://tinyurl.com/peu6b2]
If you need help with the APEX Report & Template option, please let me know.
Kind regards
Simon Gadd -
Aggregate Function in a report region does not work.
I have a Reports Region with a Region Source that contains an aggregate function. But when I run the page, the value of the function is not returned. I suspect it is a simple syntax error. can somebody tell me what is wrong with
select "TAG_PERIOD_START_DATE", MIN("ORDER_NUMBER")
from "#OWNER#"."TAG_ORDER"
group by "TAG_PERIOD_START_DATE"
order by "TAG_PERIOD_START_DATE"
The problem is probably with the MIN("ORDER_NUMBER") part. I tried several versions of that, but none worked.
The Grouping works fine -- the query returns the TAG_PERIOD_START_DATE, just not the value of the function.
BTW, this query works in SQL Plus (with the quotes removed, of course).
Thanks for any suggestion you may have.When I just made a change to the SQL, I got a message stating:
You have requested to change the Interactive Report query. If you added columns to the query, they will not be displayed when the report is run. You will need to use the actions menu and either select the columns or click Reset. If you removed any columns from the query, it will disable existing filters, highlight rules, and other report settings referencing those columns. Please confirm your request.
So maybe that was the cause of the problem yesterday. Where is the "Actions menu"? -
Aggregate function in native query (EJB 3.0)
How do you run a aggregate function in a native query? I have a particular use case, for reporting purposes, where the result set is too large to fetch the actual CMP collection, thus I need to execute a native count/avg select. I want some thing like,
Integer totalRecords = (Integer)
em.createNativeQuery("select count(*) from records").getSingleResult();Oracle is intelligent enough to use index only if query result filtering is based on it and result set is less than 5% of the total data set.Sorry to be blunt but that 5% stuff is nonsense.
Here since the index column is not used in the WHERE clause, oracle performs full table scan.That's not true either. Under the right circumstances the optimizer can use the index, even without a WHERE clause in the query:
SQL> create table t as select * from dba_objects where object_type is not null;
Table created.
SQL> alter table t modify object_type not null;
Table altered.
SQL> create index t_idx on t(object_type);
Index created.
SQL> explain plan for
2 select object_type, count(*) from t group by object_type;
Explained.
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 44 | 396 | 60 (7)| 00:00:01 |
| 1 | HASH GROUP BY | | 44 | 396 | 60 (7)| 00:00:01 |
| 2 | INDEX FAST FULL SCAN| T_IDX | 72474 | 636K| 57 (2)| 00:00:01 |
-------------------------------------------------------------------------------With the OP's query, it (apparently) can not be satisfied by using only the index.
WHERE TO_CHAR(COL) = TO_CHAR(COL)I don't even know what this means. Usually if you perform a function on an indexed column, the optimizer will not use the index (unless of course it's an fbi). -
Using aggregate function count
hi experts,
I want to select 2 fields from a table and put into structure (gw_konzs.) and with respect to that i want to use aggregate function count(*) for knowing how many rows has been selected ? and i dont want to use select & endselect
please help regarding this ...........
for example:
select konts ltext from ztab into corresponding fields of gw_konzs.
select count(*) from kna1 into gw_konzs
where konzs = gw_konzs-konzs.
append gw_konzs to gt_konzs
endselect.hi experts,
I want to select 2 fields from a table and put into structure and i want to select based on the where condition i dont want to use select & endselect
please help regarding this ...........
rewarded if useful
for example:
gw_detail & gw_konzs is structure
gt_detail & gt_konzsis internal table
select kunnr name1 from kna1 into corresponding fields of gw_detail where konzs = gw_konzs-konzs.
gw_detail-konzs = gw_konzs-konzs.
append gw_detail-konzs to gt_detail-konzs
endselect.
Maybe you are looking for
-
[SOLVED] Logitech Marble Mouse: can't enable custom mapping
I followed the wiki page: Logitech_Marble_Mouse My mouse works, but I can't get custom mappings to work. Here's my /etc/X11/xorg.conf.d/10-evdev.conf, to me it looks like it does ignore the Marble settings. What am I missing? Section "InputClass" Ide
-
Multi response for Async/Sync bridge.
Hi everyone! We have a scenario with Async/Sync Bridge. It is JDBC-BAPI-JDBC. So it uses 3 communication channels. Sender/Receiver for JDBC and Receiver for BAPI. Now we need to modify scenario so that it will send BAPI response not only to JDBC but
-
CREATING VIRTUAL DIRECTORY THROUGH jakarta-tomcat-4.1.10
dear friend(s) how to create a virtual directory through tomcat jakarta-tomcat-4.1.10 please help me very very urgent mohd meraj
-
Hi guys! I am using LiveCycle Data services 2.6 and Flash Builder 4.0.. and getting an error Only LiveCycle Data Services 2.6 or higher is supported in this version of Flash Builder. Any suggestion? why Flashbuilder is not detecting correct version?
-
Help: Custom Encoder + Netbeans 5.5.1 enterp. pack
Help me, please: All points are finished in the Installation Guide for installing CustomEncoder component (link for guide - http://www.glassfishwiki.org/jbiwiki/Wiki.jsp?page=EncoderInstallation chapter "Installation Process for NetBeans IDE 5.5.1")