Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
matthewp
Creator III
Creator III

SUM set analaysis if group contains a certain line

I have a small data set:

 

PIDPCODE               PVAL
2N50£1,000.00
2B10£100.00
2P40£500.00
3B10£100.00
3P40£500.00
4B10£100.00
4P40£500.00

I want to have a straight table that shows PID and PCODE and PVAL

Except if a PID has a PCODE of N50 in it, then their B10 needs to be reduced by 5% of the N50 like so:

 

PIDPCODE               PVAL
2N50£1,000.00
2B10£50.00
2P40£500.00
3B10£100.00
3P40£500.00
4B10£100.00
4P40£500.00

how can i do this?

6 Replies
sunny_talwar

May be this:

=If(Count(TOTAL <PID> {<PCODE = {'N50'}>}PCODE) > 0, Sum({<PCODE = {'B10'}>}PVAL)*0.50 + Sum({<PCODE -= {'B10'}>}PVAL), Sum(PVAL))

MK_QSL
MVP
MVP

or

IF(PID = Only({<PID = P({<PCODE = {'N50'}>}PID)>}PID),SUM({<PCODE = {'B10'}>}PVAL)*(1-'50%')+SUM({<PCODE -= {'B10'}>}PVAL),SUM(PVAL))

matthewp
Creator III
Creator III
Author

It works, but if i make some selections if reverts back to the original value

sunny_talwar

What selections are you making?

matthewp
Creator III
Creator III
Author

Its also only showing people who have the deduction

sunny_talwar

Unless you show what you have, I am not going to understand what you are saying