

Re: Sum if Distinct
John Witherspoon May 25, 2011 6:45 PM (in response to Kristy McGee)I'm not sure I understood. Maybe this?
sum({<[Tran Type]*={"*ACH Return*"}>} aggr(if(count(distinct LoanNbr)=1,[Tran Amt]),[Tran Type]))

Sum if Distinct
Kristy McGee May 26, 2011 8:48 AM (in response to John Witherspoon )Thanks John,
I tried that expression but got $0's. My spreadsheet has a ton of different Trans Types. I want to sum the ACH Return transaction amounts, but there are multiple loan numbers. I only want to sum the tran amounts for the ACH returns with distinct loan numbers. (However, I do want to keep multiple loan numbers in for the other types). Any suggestions? I have searched for other issues and you have unknowingly helped with those  so i know if anyone can help, you can!

Sum if Distinct
John Witherspoon May 26, 2011 1:54 PM (in response to Kristy McGee)Sorry, I guess I just don't understand what you want. Perhaps post an example file with an inline load for the data and a chart showing the results you want.

Re: Sum if Distinct
John Witherspoon May 26, 2011 3:13 PM (in response to John Witherspoon )Attached is my guess of what you want. It has two solutions, one using a calculated dimension, one using an expression. In it, Tran Type "ACH Return A" isn't in the chart because it's an ACH return with more than one loan number associated with it.

testSumForDistinct.qvw 123.8 K

Sum if Distinct
Kristy McGee May 26, 2011 5:59 PM (in response to John Witherspoon )The 1st expression gave me $7m figure (i am looking for a 200k one). The 2nd expression came up null. I have attached a spreadsheet with the full data and the number I want to get to. I have the tran type filtered, so its only ACH Returns already.

Re: Sum if Distinct
Kristy McGee May 26, 2011 6:00 PM (in response to John Witherspoon )The 1st expression gave me $7m figure (i am looking for a 200k one). The 2nd expression came up null. I have attached a spreadsheet with the full data and the number I want to get to. I have the tran type filtered, so its only ACH Returns already.

example dup loan nbrs.xlsx 69.5 K

Re: Sum if Distinct
John Witherspoon May 26, 2011 6:29 PM (in response to Kristy McGee)OK, so it looks like you want the Tran Amt from the FIRST time you encounter a given LoanNbr in your data set in the sequence you loaded it. In the attached, I load an ID field from recno() during the initial load. Then I left join to it with an order by, allowing me to set a "First?" flag. Then I use set analysis to only look at the first row for a given loan number.
LOAD *
,recno() as ID
INLINE [
LoanNbr Tran Type Tran Amt
1037553 ACH Return 176.47
...
] (delimiter is ' ');
LEFT JOIN (Data)
LOAD ID
,if(LoanNbr<>previous(LoanNbr),1) as First?
RESIDENT Data
ORDER BY LoanNbr, ID
;sum({<First?={'1'}>} "Tran Amt")

testSumForDistinct2.qvw 147.8 K






