Sum of filter
I have created report, where in the rows the Entity dimension is selected, which is further filtered by a property.
However during the output, I want only the sum of filtered entities and the not the entity details making up the details.
Howto achieve this?
Appreciate the inputs.
Hi,
Assuming you have 10 Entities coming up in the template based on your filter. Are you showing the total using local member formula? Do you want to hide the rows of the entities, and just show the total?
If yes, then you will need to do this using macro.
You can put a local member formula to get the property value of the entities, based on which you are doing the filtering. Use this column in your macro. If the cell value is = "X" (where X is the property value), hide the entire row.
Hope this helps.
Similar Messages
-
MDX - Aggregate/Sum/Manual Filter
Hi
I'm having trouble replicating the cube through MDX.
I need to show the aggregate Cash Inflow Excluding some of it's child.
I have a "Cash Inflow" hierarchy like this.
Cash Inflow $100
-Inflow Application $30
-Inflow Adjustments $20
-Inflow Claims $10
-Inflow Rollover $40
Im my cube I will untick the "Inflow Rollover" in the filter. I will get Cash Inflow with a value of $60.
How do I write an MDX, so that when I call "Cash Inflow", it will return a Cash Inflow value excluding the "Inflow Rollover"?
My basic query is below, I need to modify the Cash inflow part. So that it doesn't return a total value of $100, but a subset value of $60 (exclude "Inflow Rollover")
select non empty{
crossjoin(
{[MTD],[YTD]},
{[Opening BAL],[Cash Inflow1],[Closing BAL]}
} on columns,
non empty{
crossjoin(
[Reporting Group],[BU Sales Reporting Group 02]
} on rows
from [CUBE]
where
[Period].[Period by Financial Year].[Period].&[201312],
[Measures].[Amount]
Thanks, if anyone could point me to the right direction
Gemmo1Hi,
It's not clear where to find the "cash Inflow" aggregation in your mdx query. You will have to exclude it and include a custumor total.
An example of a "MDX - Aggregate/Sum/Manual Filter" using an attribute hierarchy and excluding one element from the aggregation:
WITH
MEMBER [Product].[Category].[All Products].[Total Without Comp.] AS
Aggregate
{[Product].[Category].[Category].MEMBERS}
{[Product].[Category].[components]}
SELECT
{[Date].[Calendar Year].[CY 2008]} ON COLUMNS
[Product].[Category].[All Products]
,[Product].[Category].[Total Without Comp.]
,[Product].[Category].[Category].MEMBERS
} ON ROWS
FROM [Adventure Works];
Philip, -
Hi all,
I've been trying to get a semi-complex measure out for over a day now but seem to be going round in circles. Most frustrating is I don't quite understand why one version throws an error, another throws out the wrong number and then whatever you guys come
up with will give me the correct answer!
I have a workbook uploaded here which I used for a different question, but majority of the data model is the same :
https://onedrive.live.com/?cid=1C0322C61F94C9E9&id=1C0322C61F94C9E9%21125
What I'm trying to do is find staff members that are at risk of burn out (eg consistently working > 8hrs a day)
My main timesheet table (Time) is as such:
StaffID (fk to staff table)
ClientID (fk to client table)
TaskID (fk to task table)
TimesheetDate (fk to date table)
EffortInHrs
my date dim is standard fare, only thing i've added is an EndOfWeekDate (eg EOWDate. sunday is the last day therefore for each date for this week the endofweekdate column = 18-jan. For last week it was 11-Jan etc) and I also have a 'last freshed date' that
shows the last time the model was refreshed
A staff member can only record time against a specific task once per day, but they can have multiple tasks across multiple clients for one day
The business rule im working with is
if they've worked more than 8hrs at least once in the last 3 weeks (dates that fall between EOWdate for 'now' minus 3 weeks and EOWdate for 'now' ), then return the sum of EffortInHrs for all clients for every day in the last 3 weeks
I've given up in getting it in one go so i'm trying to cobble together a number of calc columns and measures to get me closer.. but it all seems to stall
eg the following calc column (DailySumOfHrs)
=
CALCULATE (
SUM ( [EffortInHours] ),
FILTER (
ALLEXCEPT ( TIME, 'Time'[TimesheetDate], TIME[StaffID] ),
DATESBETWEEN (
'Date'[Date],
'time'[TimesheetDate],
'Time'[TimesheetDate]
gives me the sum of effort in hrs for the day for each staff member. I couldn't get a measure version of this working. It would either aggregate across all days/staff or give context errors.
So when I tried to take it to the next step to find the max using the same formula
=
CALCULATE (
SUM ( [EffortInHours] ),
FILTER (
ALLEXCEPT ( TIME, 'Time'[TimesheetDate], TIME[StaffID] ),
DATESBETWEEN (
'Date'[Date],
'time'[TimesheetDate],
'Time'[TimesheetDate]
I get errors, i'm guessing because i'm mixing my fact and date tables now and it doesn't know it can use the TimeSheetDate 'context' to filter.
To get the 'last 3 weeks' filter working I added the following to the date dim
=if([EndOfWeek]<[RefreshDateLocal] +7 && [EndOfWeek] > [RefreshDateLocal] -14,1,0)
i then used it in an intermediate measure to get the max at the weekly grain
WeeklyMax :=
IF (
MAX ( 'Date'[Last3WeeksFilter] ) = 1,
CALCULATE (
MAX ( TIME[DailySumOfHrs] ),
FILTER (
ALL ( 'Date'[date] ),
MAX ( 'Date'[EndOfWeek] ) = MAX ( 'Date'[EndOfWeek] )
'Date'[Last3WeeksFilter] = 1
BLANK ()
and finally the measure itself
BurntOutHrs:=if([WeeklyMax]>8,SUM([EffortInHours]),blank())
I am not happy with this at all. There are so many conditions (eg filters added) that need to be satisfied for this to return a sensible result and I need to expose a number of the 'backend' filters that users would need to add to the report to get the correct
answer.
As is, it only works for a simple Staff, date, burntouthrs report. If users attempt to create their own pivot table/chart and try to break it down by client or task it doesn't look right at all. I'd also like to be able to count how much stuff are working
long hrs but this approach wouldn't support that at all.
I could probably post dozens of my attempted dax that to me logically look like it should work but either aggregate wrong or throw context errors. Unfortunately my current approach to dax still is to try various, almost random variations until one works
for whatever reason
I always aim to have a measure that 'just works' in all contexts where it makes logical sense. For me to get that happening here i'd probably need to spend another few hrs trying all kinds of allexcept() conditions for each filter where i want it to work
and hope none contradict each other
Thinking about it now, this isn't really a separate measure at all.. i think a better approach would be to add a calc column to the staff table that checks if that staff member has >8hrs assigned for any day (i dont think the default time->staff relationship
would allow this though). But i'm still interested on how to accomplish it using the separate 'measure' approach
I'll go spend the rest of today trying to get the flag working in the staff dim!
Thanks!
Jakub @ Adelaide, Australia BlogJakubk, is this still an issue?
Thanks!
Ed Price, Azure & Power BI Customer Program Manager (Blog,
Small Basic,
Wiki Ninjas,
Wiki)
Answer an interesting question?
Create a wiki article about it! -
How many records can be displayed with fm REUSE_ALV_LIST_DISPLAY?
Hi guys!!!
Now here's is my problem. I've been trying to display in a program wih fm REUSE_ALV_LIST_DISPLAY, aproximately 450,000 records. But the fact is that after 10 or 15 minutes the system stops the process.
This case is not the same when I display with the same function a very low number of lines.
What can I do?
Maybe one possibility is using the method for ALV List (ALV List Objects)
h2Please ur answers now!
Thanks in advance!!!
Raul RomeroHi,
If you are not expecting to do any additional functionality that the ALV has, like, summing, sorting, filter...etc,
better display the result in a normal LIST.
or try to filter your results and in the selection screen, give an option to enter the number records you want to display in the report.
Regards,
Subramanian -
Need to extract non empty value thru MDX
Hi All,
I have a requirement where there are 2 measures A and B.. I need to populate the first non-missing value from a layer from A in to B..
tried using HEAD function however looks like in ASO MDX member formulas does not support this ..
Any help would be highly appreciated
Thnks,I believe the issue is that the formula you are using returns a set and you are looking for a value. Therefore, you need to use the Head function with a function that returns a numeric value (ie: Sum, Max, Avg, etc). In instances like this I typically use the Sum function. Depending on your cube and the rest of your formula, you may need to put some additional work into the formula so that the Sum returns just the value you need, but it just requires getting more specific in your arugments.
The Head formula will bring back the first member or tuples specified, but won't evaluate for non-missing. You may need to also combine the Head forumla with the Filter formula. ex: Sum(Head(Filter([Dimension or Member].SetFunction,[A] <> Missing)),1) You will mostly need to select some other dimension to apply the filter to (like period or scenario). Examples of the SetFunction are Children, Members, Levels(0), etc. If you end up going this route you may want to write out your Sum(Head()) function and and Sum(Filter()) function and validate each independently and then merge. I find this helps when trying to build larger nested functions.
Hope this helps!
Jen -
Hi experts, dialog program no solution from forum
hi all
i would like to know if there any program other than alv or oops, where icon are used ( means how to bring functionality of icons) for example, sum, subtotal, filter, xxl, spreadsheet, word procesing doc, etc.
i have developed dialog program in which i have above icons and now i want to have fuctionality of the above icons when they are clicked,( try to understand i want code to run fuctionality in dialogue prog and not how to display icons ).
thanx
rockyHi,
have a look to transactions LIBS BIBS
Fred -
Hi all dialog program experts no solution coming
hi all
i would like to know if there any program where coding for below icon is available (not in alv or oops), where icon are used ( means how to bring functionality of icons) for example, sum, subtotal, filter, xxl, spreadsheet, word procesing doc, etc.
i have developed dialog program in which i have above icons and now i want to have fuctionality of the above icons when they are clicked,( try to understand i want code to run fuctionality of icons in dialogue prog and not how to display icons ).
thanx
rockyhi all
i would like to know if there any program where coding for below icon is available (not in alv or oops), where icon are used ( means how to bring functionality of icons) for example, sum, subtotal, filter, xxl, spreadsheet, word procesing doc, etc.
i have developed dialog program in which i have above icons and now i want to have fuctionality of the above icons when they are clicked,( try to understand i want code to run fuctionality of icons in dialogue prog and not how to display icons ).
thanx
rocky -
hi all
i would like to know if there any program other than alv or oops, where icon are used for example, sum, subtotal, filter, xxl, spreadsheet, word procesing doc, etc.
i have to use these icons in my dialog program.
my other question is how to achieve sum and subtotal in dialog program. in my program i have created table control and in that for some fields i need to show total and subtal, pl guide on this urgently.
thanx
rockyHi,
Concerning the icons you can always execute transaction ICON to see the list of existing iconsin SAP
To display an icon either use you have sevarl ways to do this:
WRITE: '@OV@' TO L_STRING.
WRITE: ICON_OKAY AS ICON
Regards -
Sum of rows without Filter impact
Hi,
I've department, category( as charaterstic) in rows and sales in coloumns.
But my requirement is if I filter on departmnet the total result remains the same no change on total sum.
Whereas against the filter value only filter value is displayed which is obvious.
Pls advice.
Thx
Rit is not being answered but still I'm closing it
-
Sum the value of look up table based on two filter criteria
Hello Everyone
I am new to Powerpivot and would appreciate if someone could help me on the following problem.
You can download the example of this excel file form the following DropBox link:
Dropbox Link
The first table is tOrders
Week number
Work center
order number
Production time in minutes
2
a
111
60
2
a
112
70
2
b
113
60
3
b
114
50
3
a
115
40
3
b
116
60
4
a
117
90
4
b
118
40
The second is dLookupList
Week number
Work center
mantenace in minutes per week
Break dows in minutes per week
2
a
10
10
2
b
20
5
3
a
15
12
3
b
30
10
4
a
20
10
4
b
10
10
I’m trying to create Pivot that has filter on Week number to show the number of orders, Sum of Production time in minutes and the total of the values form the lookup table dLookupList that matches the work center and the selected week
numbers. So that I can calculate the total time for each work center. Filter criteria is Week number and Work center.
For example if someone select all weeks numbers the result sould look like this
Week number
(All)
Work center
Count of order number
Sum of Production time in minutes
mantenace in minutes per week
Break dows in minutes per week
Total time
a
4
260
45
32
337
b
4
210
60
25
295
Grand Total
8
470
Result for week 2
Week number
2
Work center
Count of order number
Sum of Production time in minutes
mantenace in minutes per week
Break dows in minutes per week
Total time
a
2
130
10
10
150
b
1
60
20
5
85
Grand Total
3
190
How can I relate these two tables to get the above result?
Any help is highly appreciated.
Regards
PriyanHi Recio
Thank you very much for the swift response. I was able to get it work.
I got two questions:
How do you add a total time column to the pivot table like you did? Because there are no calculated field in power pivot.
I prefer that the filter is based on the Orders table. So that if you select all Week numbers in the filter, that pivot will show result for all orders and relevant sums from the lookup list.
Link download the example file
For example: I add Week number 5 to the work center “a”
Week number
Work center
WNandWC
mantenace in minutes per week
Break dows in minutes per week
2
a
WN2WCa
10
10
2
b
WN2WCb
20
5
3
a
WN3WCa
15
12
3
b
WN3WCb
30
10
4
a
WN4WCa
20
10
4
b
WN4WCb
10
10
5
a
WN5WCa
1
1
In the orders table there are no records for week number 5
Week number
Work center
WNandWC
order number
Production time in minutes
2
a
WN2WCa
111
60
2
a
WN2WCa
112
70
2
b
WN2WCb
113
60
3
b
WN3WCb
114
50
3
a
WN3WCa
115
40
3
b
WN3WCb
116
60
4
a
WN4WCa
117
90
4
b
WN4WCb
118
40
4
a
WN4WCa
119
50
But the pivot sums up the week number 5 also.
Do you have any idea how to solve it?
Thank you very much.
Regards
Priyan -
Dear All,
I have problem to sum data using filter/conditon
i want to sum data like this:
No Budget SM GG
1.2 *400 200*
1.2.1 100 100
1.2.2 200 200
1.2.3 300 300
1.3 400 400
and using
<?sum(current-group()/TotalPrice[.!='' and PaymentAllocation='GG'])?>
but show no data
i also tried
<?xdoxslt:set_variable($_XDOCTX, ’INITGG’, xdoxslt:get_variable($_XDOCTX, ’INITGG’)
+xdoxslt:ifelse(PaymentAllocation='GG',xdoxslt:ifelse(TotalPrice[.!=''],TotalPrice,0),0))?>
but nothing happen, seem the code didn't recognized the group(have 2 group inside)
Please help me
Thank so much
Regards
CeciliaYou can use <?sum(current-group()/TotalPrice[.!='' and ../PaymentAllocation='GG'])?>
-
Filter by Sum without Grouping
i have a resultset that i generate from a query that Looks like this:
Select Employee, Month,
(select case
when Status = '---'
then 0 Else
1 end) as PlaningValue
From PlanningTable PT
Where Month >=
@From Month and Month
<= @ToMonth
The Result of this Looks something like this:
|Employee| Month
| PlaningValue |
|George |2014-01
|
1 |
|George |
2014-02 |
1 |
|George |
2014-03 | 0
|
|Andrew |
2014-01 |
0 |
|Andrew |
2014-02 |
1 |
|Andrew |
2014-03 |
0 |
|Howard |
2014-01 |
1 |
|Howard |
2014-02 |
1 |
|Howard |
2014-03 | 1
|
Now what i want is the following:
Filter out Employee's who, over the three month period, have a total planing Value of 3, in the example above, Howard would be filtered out.
Is there a way to do this nicely or is it all just impossible to even thin ?
(Remark: Since i am going to use the Query on Reporting Services, i can't use the OVER function)
Thank you all for your helpJingyang's answer is a top choice, assuming SQL Server 2005 or greater (you didn't say what version, everybody should!). I wrote up a version doing the same thing before I noticed Jinyang's answer already was here. The last item in the list is
a derived query version, same net effect as using the WITH statement.
Create_Demo_table:
Declare @Demo Table (employee varchar(99), month varchar(77), status int)
Insert @Demo
Select 'George', '2014-01 ', 1
UNION ALL Select 'George', '2014-02', 1
UNION ALL Select 'George', '2014-03', 0
UNION ALL Select 'Andrew', '2014-01', 0
UNION ALL Select 'Andrew', '2014-02', 1
UNION ALL Select 'Andrew', '2014-03', 0
UNION ALL Select 'Howard', '2014-01', 1
UNION ALL Select 'Howard', '2014-02', 1
UNION ALL Select 'Howard', '2014-03', 1
With_Stmt:
;With X as
Select *
, sum(status) over(partition by employee) as sumStat
from @Demo
where month between '2014-01' and '2014-03'
Select * from X where SumStat < 3
Derived_query:
Select * from
Select *
, sum(status) over(partition by employee) as sumStat
from @Demo
where month between '2014-01' and '2014-03'
) Derived1
where Sumstat < 3 -
Summing data for a period when a filter is available
I have the following fields in my report
Company , Date, Days Budget, MTD Budget, YTD budget .
I need to add a column to the same report to indicate the Total Budget for the year. Which is the sum of Days budget field for the entire year . This needs to be shown even if a filter is added to the date column.
Currently when I add the filter, the Total Budget will be computed only up to the date defined in the filter. Is there any other way of achieving this?You have to "lock"the hierarchy level in de repository.
Add a copy of Days Budget to your RPD , rename it Total budget, set the hierarchy level to Year
Regards
John
http://www.obiee101.blogspot.com/ -
SSRS 2008 R2 Report - Sum Totals of a Filtered Group
I'm at a loss here, so any help will me much appreciated. I will do my best to explain, but if you need additional information, please let me know:
I have a very large dataset of patient data. Specifically for the numbers I need, I have a patient number field, a county field, a 1 or 0 for LastYear field, and a 1 or 0 for CurrentYear field.
Example:
PtNo County PY CY
45676 Scott 0 1
45322 Cape 1 0
47686 North 0 1
The thing I am shooting for on my report is, "Volume growth in 3 counties (+20 cases)."
I created a group and grouped by County (group name County) and I included a group filter to only include "total cases of CY" are greater than "total cases of PY" to narrow my data to only counties that had a higher current year sum
than previous year sum.
Example:
County PY CY Difference
Scott 141 143 2
Cape 90 98 8
North 78 88 10
All is working well, except I don't need to see the Counties themselves, I just need the 3 counties and a difference of 20.
I explored online and found tutorials that said to right click on the field and select "Add Total" but this total did not have my filter in it and gave me everyone. I also tried adding a row outside the group and used the RunningValue function
(i.e. RunningValue(Fields!FYTD_Current_Year.Value, Sum, "County")) but it gave me a message that states "The Value expression for the text box 'Textbox456' has a scope parameter that is not valid for an aggregate function. The scope
parameter must be set to a string constant that is equal to either the name of a containing data region or the name of a dataset."
When I move the row with the RunningValue function inside the group, it runs but I get the same information repeated twice for each county with no final total.
So I am not sure how to go about getting my values I need for my report. Anybody know how to resolve this?
Thanks,
Cyndi
cpemtp1Hi Cyndi,
Based on my understanding, you specify a filter condition in group properties. Then you want to sum the filtered values for each field.
In this scenario, we need to specify a filter condition on group level. If we use sum() function out of group, the expression will calculate the total values on dataset level instead of group level. So we can’t simply use expression to achieve this goal.
However, we can use custom code to record the filtered values for each field, then we can calculate the total based on these values. Please refer to the steps and screenshots below:
1. Add the custom code below into the report:
Public Shared Value1 as Integer=0
Public Shared Function GetValue1(Item as Integer) as Integer
value1= value1 + Item
return Item
End Function
Public Shared Function GetTotal1()
return value1
End Function
Public Shared Value2 as Integer=0
Public Shared Function GetValue2(Item as Integer) as Integer
value2= value2 + Item
return Item
End Function
Public Shared Function GetTotal2()
return value2
End Function
2. Design the tablix like below:
3. The result looks like below:
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu -
I want to add a column after Total lets say..'Progress' where Progress = sum(Actual)/sum(Budget)
The only filter on Progress is to consider only those values from months where both Actual and Budget are present.
So, e.g.
For first row: 0/0 = 0
For second row: 0/0 = 0
For third row: 28334/67060(instead of 200511) = 0
if there would have been an Actual value for the month of August e.g. 100, then (28334+100)/(67060+66614)
For fourth row: 0/0 = 0
How can I achieve this using expressions in SSRS?
Thanks in advancHi rockstar283,
As per my understanding, you want to add a column names Progress, it is calculated from the values of Actual and Budget. In current month, Progress = sum(Actual)/sum(Budget), else, it is set to 0. If so, please refer to the following expression:
=IIF(Month(Fields!pmonth.Value)=Month(Today()),Sum(Fields!Actual.Value),0)/IIF(Sum(Fields!budget.Value)=0,1,Sum(Fields!budget.Value))
The following screenshot is for your reference:
If my understanding is not correct, please feel free to let me know. I would appreciate it if you could give us detailed description of your requirements, it’s also better to provide the table structure and some sample data. It will help us move more quickly
toward a solution.
Thanks,
Wendy Fu
Maybe you are looking for
-
Mixing MAX Task under one Start/Stop
Hi, I have an end-of-line app that is testing some radio boards. These tests will require turnng on/off the some digital lines, reading some analog values and some RS-232 communications, sorta async stuff for the most part. I have defined several s
-
Change client in scenarios with SAP business system
Did you ever wonder how you can change the client of a Business System and it's related communication channels in scenarios that make use of SAP systems? One might think that changing the client in the communication channel (sender and/or receiver) i
-
Two iPhones, two computers, one family MobileMe account
My wife has an iPhone and a MacBook. I have an iPhone and a MacBook Pro. We have separate IDs on one MobileMe family plan. Up til now when I update my iCal on my Mac it shows up in her iCal on her Mac and visa-versa. But the only way to get that info
-
USB optical mouse won't work in PS/2 port
I have a lenovo USB optical wheel mouse that I want to plug into the PS/2 mouse port (I need to free up the USB port for something else). I have a green USB to PS/2 adaptor that works fine with a borrowed logitech USB mouse and also works fine with
-
Using Pages on iPad mini retina
We opened Pages & were looking at the list of documents saved when it suddenly went blank showing the message "No documents". We have now been unable to find those documents, so would appreciate any help in restoring them & stop it happening in futu