Forum Discussion
Data Transformation using VBA like subtotal
- Oct 01, 2024
Thanks a lot its work like a charm, I was not aware of we can achieve this by using Power Query.
I need minor change where we are filling ATI number (Invoice output to customer) is multiple in same CPO then in its description I need respective ATI number for example in below example we have 3 different ATI in that case description of summary should contains final output as below :-
Invoice and Tax date Site ID CPO Sales Order number WBS Quantity Unit Price Invoice value ATI number (Invoice output to customer)
8/27/2028 56311 111 581986985 ETL14.100005/04105 0.7 6,048.23 4,233.76 1
8/27/2029 12614 111 581986985 ETL14.100005/04104 0.3 6,048.23 4,233.76 2
8/27/2031 25543 111 581986985 ETL14.100005/04115 0.3 6,048.23 4,233.76 3
Total 12,701.28 "1 Site 70% PO 111 ATI 1
1 Sites 30% PO 111 ATI 2
1 Sites 30% PO 111 ATI 3"
Hi MyQueries
I need minor change... It's probably not a minor change. The info./example you shared leads to different possible interpretations/results
==> Share (with OneDrive, Google Drive... or the like) a sample representative workbook with a couple of examples showing what you have & what you expect - each example being different/representing your different possible scenarios
- MyQueriesOct 01, 2024Copper Contributor
Lorenzo sorry for that, I also noticed later when checked in whole dataset.
I have updated the file in below given link. let me know if you are able to access it ?
https://1drv.ms/x/s!Ap80Ku6M2Tw5g1oVHtkj2oZUelJd?e=PZRyzJ
- LorenzoOct 01, 2024Silver Contributor
Can't access the file you shared 😞 Could you try again please?
- MyQueriesOct 01, 2024Copper ContributorPlease try now
https://1drv.ms/x/s!Ap80Ku6M2Tw5g1lEf4e3NgpHZJBl?e=aIAEpM
- peiyezhuOct 01, 2024Bronze Contributor
sql:
select * from GenerateSubtotal limit 20;
create temp table aa as
select 'a'||f03||'t' ord,'' f01,'Total' f02,f03,
colIdxf[3:6]{'' %s}, sum(cast(replace(f08,',','') as double)) f08,
f09,f10,f11,f12,f13,f14,f15,f16 from GenerateSubtotal group by f03 order by ord;
create temp table bb as
select f03,group_concat(ATI,'<br>') f09 from (select f03,f06,count(f06)||' site '||cast(f06*100 as text)||'% ATI '||f09 ATI from GenerateSubtotal group by f03,f06,f09) group by f03;// change group from f03,f06 to f03,f06,f09
//select * from bb;
create temp table cc as
select ord,f01,f02,'' f03,f04,f05,f06,f07,f08,bb.f09,f10,f11,f12,f13,f14,f15,f16 from aa join bb using(f03);
//select * from cc;
create temp table dd as
select 'a'||f03 ord,* from GenerateSubtotal union all select * from cc order by ord;
select colIndex[1:] from dd;f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 f11 f12 f13 f14 f15 f16 27.08.2024 14140 1 11 WBS1 0.7 6,048.23 4,233.76 1 Dummy Testing Testing Testing Testing Testing Testing 27.08.2025 66097 2 22 WBS2 0.7 6,048.23 4,233.76 2 Dummy Testing Testing Testing Testing Testing Testing 27.08.2026 34541 3 33 WBS1 0.7 6,048.23 4,233.76 3 Dummy Testing Testing Testing Testing Testing Testing 27.08.2027 98604 1 11 WBS2 0.3 6,048.23 4,233.76 4 Dummy Testing Testing Testing Testing Testing Testing 27.08.2028 56311 4 44 WBS1 0.7 6,048.23 4,233.76 5 Dummy Testing Testing Testing Testing Testing Testing 27.08.2029 12614 4 44 WBS2 0.3 6,048.23 4,233.76 2 Dummy Testing Testing Testing Testing Testing Testing 27.08.2030 96919 5 55 WBS1 0.7 6,048.23 4,233.76 6 Dummy Testing Testing Testing Testing Testing Testing 27.08.2031 25543 4 44 WBS2 0.3 6,048.23 4,233.76 7 Dummy Testing Testing Testing Testing Testing Testing 27.08.2032 58155 2 22 WBS2 0.3 6,048.23 4,233.76 8 Dummy Testing Testing Testing Testing Testing Testing 27.08.2030 96919 5 55 WBS1 0.7 6,048.23 4,233.76 6 Dummy Testing Testing Testing Testing Testing Testing 27.08.2030 96919 5 55 WBS1 0.3 6,048.23 4,233.76 6 Dummy Testing Testing Testing Testing Testing Testing 27.08.2031 25543 4 44 WBS2 0.3 6,048.23 4,233.76 7 Dummy Testing Testing Testing Testing Testing Testing f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 f11 f12 f13 f14 f15 f16 27.08.2024 14140 1 11 WBS1 0.7 6,048.23 4,233.76 1 Dummy Testing Testing Testing Testing Testing Testing 27.08.2027 98604 1 11 WBS2 0.3 6,048.23 4,233.76 4 Dummy Testing Testing Testing Testing Testing Testing Total 8467.52 1 site 30.0% ATI 4 Dummy Testing Testing Testing Testing Testing Testing 1 site 70.0% ATI 1 27.08.2025 66097 2 22 WBS2 0.7 6,048.23 4,233.76 2 Dummy Testing Testing Testing Testing Testing Testing 27.08.2032 58155 2 22 WBS2 0.3 6,048.23 4,233.76 8 Dummy Testing Testing Testing Testing Testing Testing Total 8467.52 1 site 30.0% ATI 8 Dummy Testing Testing Testing Testing Testing Testing 1 site 70.0% ATI 2 27.08.2026 34541 3 33 WBS1 0.7 6,048.23 4,233.76 3 Dummy Testing Testing Testing Testing Testing Testing Total 4233.76 1 site 70.0% ATI 3 Dummy Testing Testing Testing Testing Testing Testing 27.08.2028 56311 4 44 WBS1 0.7 6,048.23 4,233.76 5 Dummy Testing Testing Testing Testing Testing Testing 27.08.2029 12614 4 44 WBS2 0.3 6,048.23 4,233.76 2 Dummy Testing Testing Testing Testing Testing Testing 27.08.2031 25543 4 44 WBS2 0.3 6,048.23 4,233.76 7 Dummy Testing Testing Testing Testing Testing Testing 27.08.2031 25543 4 44 WBS2 0.3 6,048.23 4,233.76 7 Dummy Testing Testing Testing Testing Testing Testing Total 16935.04 1 site 30.0% ATI 2 Dummy Testing Testing Testing Testing Testing Testing 2 site 30.0% ATI 7 1 site 70.0% ATI 5 27.08.2030 96919 5 55 WBS1 0.7 6,048.23 4,233.76 6 Dummy Testing Testing Testing Testing Testing Testing 27.08.2030 96919 5 55 WBS1 0.7 6,048.23 4,233.76 6 Dummy Testing Testing Testing Testing Testing Testing 27.08.2030 96919 5 55 WBS1 0.3 6,048.23 4,233.76 6 Dummy Testing Testing Testing Testing Testing Testing Total 12701.28 1 site 30.0% ATI 6 Dummy Testing Testing Testing Testing Testing Testing 2 site 70.0% ATI 6