Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to summary in set analysis by dimension

I have 2 table

first table

ParentChildCodeBudget
AAA1100
AAAA1200
AAAAA1300
BBB1300
CCC250
CCCC21500

second table

CodeFromToDiscount
1135010%
135199999930%
21305%
231160020%
2160199999940%

Those 2 table already link by code. I want to summary budgets and find the discount within range from and to in a new pivot chart.

Pivot chart

ParentChildBudgetDiscount Cal (Correct)Discount Cal (by my expression)
AAA10030%30%
AAA20030%30%
AAAA30030%30%
Total Child60030%30%
BBB30010%30%
Total Child30010%30%
CCC5020%40%
CCC150020%40%
Total Child155020%40%
Total Parent2450--

the expression that I use in 'discount cal' column

Only({$<From={"<=$(=Sum(Budget))"},To={">=$(=Sum(Budget))"}>} Discount)

My problem is the 'discount cal' that i get is max discount. Somebody help me to solve my problem.

thank you.

11 Replies
hic
Former Employee
Former Employee

You should fix this in the script using intervalmatch. For example:

Hierarchy:
Load * From Table1 (…) ;

Discounts:
Load * From Table2 (…) ;

Left Join (Hierarchy)
IntervalMatch (Budget, Code)
Load From, To, Code Resident Discounts;

Left Join (Hierarchy)
Load * Resident Discounts;

Drop Table Discounts;

But what I don't understand is how you can say that AA should have 30% discount. A budget of 100 implies 10%, not 30%.

HIC

Digvijay_Singh

See if this is correct, followed the advice from Henric

Your correct column is not reflecting right percentage it seems, please verify -

discount.PNG

Not applicable
Author

Thank you 'Digvijay Singh' and 'Henric Cronstrom' for the answer but it's not correct for this because the budget as calculate for discount is summary total budget group by parent for example AA,AAA,AAAA the budget for cal discount is 600 so that mean this group have discount is 600.

Why I not use interval match because the budget had controlled by month and year that mean the discount not fixable if i change to see another year. Could you have another way?

Thank you

Digvijay_Singh

We can apply interval match to sub of budget group By Parent. But need some extra script.

Check this out -

range.PNG

Not applicable
Author

Thank you Digvijay Singh, In my opinion this way is mean it be fix summary budget but my budget is control by month and year. Sorry, again I think my table make you something wrong because that table is my pivot table but the raw budget table like this.


ParantChildBudgetCodeDateMonthYear
AAA50101/01/2014Jan2014
AAA30101/01/2015Jan2015
AAAA100113/01/2015Jan2015
AAAA100101/03/2015Mar2015
AAAAA150102/03/2015Mar2015
AAAAA150110/03/2015Mar2015
BBB100101/01/2014Jan2014
BBB50101/02/2014Feb2014
BBB150101/03/2015Mar2015
CCC50201/01/2014Jan2014
CCCC500201/02/2014Feb2014
CCCC500201/02/2015Feb2015
CCCC500201/03/2015Mar2015

That mean the summary of budget should be dynamic with month and year selection. This is my reason to find solution for expression not in load script(If I use load script it's mean size of file is very very big).

Thank you.

hic
Former Employee
Former Employee

Let's see if I have understood this correctly:

You want an assignment of Discount per combination of Parent and YearMonth. I.e. within each such combination there is only one Discount assigned. Right?

Further, you want a static assignment. I.e. the Discount for a specific Parent-YearMonth should not change just because the user makes a selection in some other field, e.g. Date or Child. Right?

If so, I'd say that an IntervalMatch in the script is the correct solution - but the IntervalMatch should be made on the aggregated budget number. Hence:

Data:
Load * From Table1 (…) ;

Left Join (Data) Load
   Parent, Year, Month,
   Sum(Budget) as AccumulatedBudget
   Resident Data Group By Parent, Year, Month;

Discounts:
Load * From Table2 (…) ;

Left Join (Data) IntervalMatch (AccumulatedBudget, Code)
Load From, To, Code Resident Discounts;

Left Join (Data)
Load * Resident Discounts;
Drop Table Discounts;

HIC

Not applicable
Author

Thank you for answer Henric Cronström,


    If i not wrong this solution mean I must select Parent, Year and month so result will be correct right? If I select year only and show all parent child and month? that why I should find dynamic solution.


Thank you

Digvijay_Singh

If you want the change of discount percentage based on your selections(like If you select only Parent 'A' and 2015, and you dynamically want to add up all budget values matching with this combination disregarding month and child and then want to apply discount percentage), It seems very very complex to me.

But if you would want to add more dimensions like Year and Month along with Parent, it won't require much change in the previous solution suggested, you can add Year and Month with Parent in Group By statement and after load.

But I suspect if you have something related to  the first thing I mentioned above.

Not applicable
Author

Thank you Digvijay Singh,


The bad news as I want is the first thing