function exportPptFlag()
{
    var data=trends1Data;
            
    let pptx = new PptxGenJS();
    let slide = pptx.addSlide();
    let slide2 = pptx.addSlide();

    let opts1 = { x: 0.13, y: 0.05, w: 6.06, h: 0.30, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let opts1_2 = { x: 0.13, y: 0.05, w: 6.06, h: 0.30, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let opts2 = { x: 0.20, y: 0.42, w: 3.05, h: 0.35, fontFace: "Arial", fontSize: 13, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.roundRect };
    let opts3 = { x: 0.20, y: 0.90, w: 2.50, h: 0.30, fontSize: 10, fontFace: 'Arial', bold: true, color: '002a5c' };
    let opts3a = { x: 0.20, y: 1.20, w: 3.97, h: 0.21, fontSize: 8, fontFace: 'Arial', bold: false, color: '969696' };
    let opts4a = { x: 7.24, y: 1.20, w: 2.54, h: 0.21, fontSize: 8, fontFace: 'Arial', bold: false, color: '969696' };
    let opts4 = { x: 7.20, y: 0.90, w: 2.78, h: 0.30, fontSize: 10, fontFace: 'Arial', bold: true, color: '002a5c' };
    let opts5 = { x: 1.31, y: 1.81, w: 0.94, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts6 = { x: 2.09, y: 1.76, w: 0.82, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts7 = { x: 2.94, y: 1.76, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts8 = { x: 3.79, y: 1.76, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts9 = { x: 4.57, y: 1.76, w: 0.85, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts10 = { x: 5.39, y: 1.76, w: 0.87, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts11 = { x: 6.22, y: 1.76, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let opts12 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts16 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let opts17 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };

    let opts18 = { x: 1.41, y: 2.25, w: 0.65, h: 0.40, fill: 'd6e6fd', line: { color: 'd6e6fd' } };
    let opts18a = { x: 1.41, y: 2.25, w: 0.65, h: 0.40, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: '000000' };
    let opts19 = { x: 1.41, y: 2.82, w: 0.63, h: 0.40, fill: '71a7ff', line: { color: '71a7ff' } };
    let opts19a = { x: 1.41, y: 2.82, w: 0.63, h: 0.40, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: 'ffffff' };
    let opts20 = { x: 1.45, y: 3.44, w: 0.56, h: 0.38, fill: '156eff', line: { color: '156eff' } };
    let opts20a = { x: 1.45, y: 3.44, w: 0.56, h: 0.38, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: 'ffffff' };
    let opts21 = { x: 1.45, y: 4.04, w: 0.50, h: 0.37, fill: '0046b8', line: { color: '0046b8' } };
    let opts21a = { x: 1.45, y: 4.04, w: 0.50, h: 0.37, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: 'ffffff' };
    let opts22 = { x: 2.19, y: 2.25, w: 0.65, h: 0.40, fill: 'd6e6fd', line: { color: 'd6e6fd' } };
    let opts22a = { x: 2.19, y: 2.25, w: 0.65, h: 0.40, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: '000000' };
    let opts23 = { x: 2.24, y: 2.82, w: 0.63, h: 0.40, fill: '71a7ff', line: { color: '71a7ff' } };
    let opts23a = { x: 2.24, y: 2.82, w: 0.63, h: 0.40, align: 'center', fontSize: 9, bold: true, color: 'ffffff', fontFace: "Arial" };
    let opts24 = { x: 2.27, y: 3.44, w: 0.56, h: 0.38, fill: '156eff', line: { color: '156eff' } };
    let opts24a = { x: 2.27, y: 3.44, w: 0.56, h: 0.38, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: 'ffffff' };
    let opts25 = { x: 2.28, y: 4.04, w: 0.50, h: 0.37, fill: '0046b8', line: { color: '0046b8' } };
    let opts25a = { x: 2.28, y: 4.04, w: 0.50, h: 0.37, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: 'ffffff' };
    let opts26 = { x: 3.02, y: 2.25, w: 0.65, h: 0.40, fill: 'd6e6fd', line: { color: 'd6e6fd' } };
    let opts26a = { x: 3.02, y: 2.25, w: 0.65, h: 0.40, align: 'center', fontFace: "Arial", fontSize: 9, bold: true, color: '000000' };
    let opts27 = { x: 3.06, y: 2.82, w: 0.63, h: 0.40, fill: '71a7ff', line: { color: '71a7ff' } };
    let opts27a = { x: 3.06, y: 2.82, w: 0.63, h: 0.40, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: 'ffffff' };
    let opts28 = { x: 3.09, y: 3.44, w: 0.56, h: 0.38, fill: '156eff', line: { color: '156eff' } };
    let opts28a = { x: 3.09, y: 3.44, w: 0.56, h: 0.38, align: 'center', fontFace: "Arial", fontSize: 9, bold: true, color: 'ffffff' };
    let opts29 = { x: 3.10, y: 4.04, w: 0.50, h: 0.37, fill: '0046b8', line: { color: '0046b8' } };
    let opts29a = { x: 3.10, y: 4.04, w: 0.50, h: 0.37, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: 'ffffff' };
    let opts30 = { x: 3.84, y: 2.25, w: 0.65, h: 0.40, fill: 'd6e6fd', line: { color: 'd6e6fd' } };
    let opts30a = { x: 3.84, y: 2.25, w: 0.65, h: 0.40, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: '000000' };
    let opts31 = { x: 3.89, y: 2.82, w: 0.63, h: 0.40, fill: '71a7ff', line: { color: '71a7ff' } };
    let opts31a = { x: 3.89, y: 2.82, w: 0.63, h: 0.40, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: 'ffffff' };
    let opts32 = { x: 3.92, y: 3.44, w: 0.56, h: 0.38, fill: '156eff', line: { color: '156eff' } };
    let opts32a = { x: 3.92, y: 3.44, w: 0.56, h: 0.38, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: 'ffffff' };
    let opts33 = { x: 3.93, y: 4.04, w: 0.50, h: 0.37, fill: '0046b8', line: { color: '0046b8' } };
    let opts33a = { x: 3.93, y: 4.04, w: 0.50, h: 0.37, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: 'ffffff' };
    let opts34 = { x: 4.67, y: 2.25, w: 0.65, h: 0.40, fill: 'd6e6fd', line: { color: 'd6e6fd' } };
    let opts34a = { x: 4.67, y: 2.25, w: 0.65, h: 0.40, align: 'center', fontSize: 9, fontFace: "Arial", bold: true, color: '000000' };
    let opts35 = { x: 4.71, y: 2.82, w: 0.63, h: 0.40, fill: '71a7ff', line: { color: '71a7ff' } };
    let opts35a = { x: 4.71, y: 2.82, w: 0.63, h: 0.40, align: 'center', fontFace: "Arial", fontSize: 9, bold: true, color: 'ffffff' };
    let opts36 = { x: 4.74, y: 3.44, w: 0.56, h: 0.38, fill: '156eff', line: { color: '156eff' } };
    let opts36a = { x: 4.74, y: 3.44, w: 0.56, h: 0.38, align: 'center', fontFace: "Arial", fontSize: 9, bold: true, color: 'ffffff' };
    let opts37 = { x: 4.75, y: 4.04, w: 0.50, h: 0.37, fill: '0046b8', line: { color: '0046b8' } };
    let opts37a = { x: 4.75, y: 4.04, w: 0.50, h: 0.37, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: 'ffffff' };
    let opts38 = { x: 5.49, y: 2.25, w: 0.65, h: 0.40, fill: 'd6e6fd', line: { color: 'd6e6fd' } };
    let opts38a = { x: 5.49, y: 2.25, w: 0.65, h: 0.40, align: 'center', fontSize: 9, bold: true, fontFace: "Arial", color: '000000' };
    let opts39 = { x: 5.54, y: 2.82, w: 0.63, h: 0.40, fill: '71a7ff', line: { color: '71a7ff' } };

        
    let opts39a =  {"x": 5.54,"y": 2.82,"w": 0.63,"h": 0.40,align: 'center',fontSize: 9,fontFace: "Arial",bold: true,color: 'ffffff'};
    let opts40 =  {"x": 5.57,"y": 3.44,"w": 0.56,"h": 0.38,fill: '156eff',line: { color: '156eff' }};  
    let opts40a =  {"x": 5.57,"y": 3.44,"w": 0.56,"h": 0.38,align: 'center',fontSize: 9,bold: true,fontFace: "Arial",color: 'ffffff'}; 
    let opts41 =  {"x": 5.57,"y": 4.04,"w": 0.50,"h": 0.37,fill: '0046b8',line: { color: '0046b8' }};  
    let opts41a =  {"x": 5.57,"y": 4.04,"w": 0.50,"h": 0.37,align: 'center',fontSize: 9,fontFace: "Arial",bold: true,color: 'ffffff'}; 
    let opts42 =  {"x": 6.31,"y": 2.25,"w": 0.65,"h": 0.40,fill: 'd6e6fd',line: { color: 'd6e6fd' }};
    let opts42a =  {"x": 6.31,"y": 2.25,"w": 0.65,"h": 0.40,align: 'center',fontSize: 9,fontFace: "Arial",bold: true,color: '000000'};
    let opts43 =  {"x": 6.36,"y": 2.82,"w": 0.63,"h": 0.40,fill: '71a7ff',line: { color: '71a7ff' }};  
    let opts43a =  {"x": 6.36,"y": 2.82,"w": 0.63,"h": 0.40,align: 'center',fontSize: 9,bold: true,fontFace: "Arial",color: 'ffffff'};  
    let opts44 =  {"x": 6.39,"y": 3.44,"w": 0.56,"h": 0.38,fill: '156eff',line: { color: '156eff' }};  
    let opts44a =  {"x": 6.39,"y": 3.44,"w": 0.56,"h": 0.38,align: 'center',fontSize: 9,bold: true,fontFace: "Arial",color: 'ffffff'};
    let opts45 =  {"x": 6.40,"y": 4.04,"w": 0.50,"h": 0.37,fill: '0046b8',line: { color: '0046b8' }};  
    let opts45a={"x": 6.40,"y": 4.04,"w": 0.50,"h": 0.37,align: 'center',fontSize: 9,fontFace: "Arial",bold: true,color: 'ffffff'};
    let opts46={"x": 1.33,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts47={"x": 2.15,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts48={"x": 2.97,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts49={"x": 3.79,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts50={"x": 4.61,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts51={"x": 5.42,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts52={"x": 6.24,"y": 4.54,"w": 0.76,"h": 0.30,fontSize: 8,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts53={"x": 8.17,"y": 4.53,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let opts54={"x": 9.13,"y": 4.53,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
    let logoPosition = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logoPosition1 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};

    let opttnpa = {x: 1.85,y: 1.41,w: 5.38,h: 3.42,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};

    var DairycountryLevel = data['ConsumptionCountry'];
    var DairyquarterLevel = data['ConsumptionQuarter'];
                        
    var DairyfinalTrendData = [];
    var DairyfinalTrendDataX = [];

    var Q1 = DairyquarterLevel["Q1'25"];
    var Q2 = DairyquarterLevel["Q2'25"];
    
    var DairybaseData = [Q1.ever[0].bCount, Q2.ever[0].bCount];
    var DairyeverData = [Q1.ever[0].percentage, Q2.ever[0].percentage];
    var Dairyconsumed1YData = [Q1.consumed1Y[0].percentage, Q2.consumed1Y[0].percentage];
    var Dairyconsumed3MData = [Q1.consumed3M[0].percentage, Q2.consumed3M[0].percentage];
    var Dairyconsumed7DData = [Q1.consumed7D[0].percentage, Q2.consumed7D[0].percentage];
            
    DairyfinalTrendData.push(DairyeverData);
    DairyfinalTrendData.push(Dairyconsumed1YData);
    DairyfinalTrendData.push(Dairyconsumed3MData);
    DairyfinalTrendData.push(Dairyconsumed7DData);
    
    var DairyeverDataCountry = [];
    var Dairyconsumed1YDataCountry = [];
    var Dairyconsumed3MDataCountry = [];
    var Dairyconsumed7DDataCountry = [];

    const DairycountryData = {};

    countryLabel4.forEach(country => {
        if (DairycountryLevel[country]) {
            DairycountryData[country] = DairycountryLevel[country];
        }
    });

    for (let country in DairycountryData) {
        DairyeverDataCountry.push(DairycountryData[country].ever[0].percentage);
        Dairyconsumed1YDataCountry.push(DairycountryData[country].consumed1Y[0].percentage);
        Dairyconsumed3MDataCountry.push(DairycountryData[country].consumed3M[0].percentage);
        Dairyconsumed7DDataCountry.push(DairycountryData[country].consumed7D[0].percentage);
    }

    const DairybCounts = {};
    const Dairycountries = Object.keys(DairycountryData);

    Dairycountries.forEach((country, index) => {
        DairybCounts[index] = DairycountryLevel[country].ever[0].bCount;
    });

    const DairyflatArray = Object.values(DairybCounts);
    const ConsumptionFunnelArray = [{
        title: "Consumption Funnel",
        subtitle: "Dairy Milk (Flavored & Unflavored)",
        subtitle1: "Half Yearly (H1’25)",
        subtitle3: "Quarterly – SEA",
        countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
        
        ever:DairyeverDataCountry,
        consumed1:Dairyconsumed1YDataCountry,
        consumed3:Dairyconsumed3MDataCountry,
        consumed7:Dairyconsumed7DDataCountry,
        
        funnel: ["","Ever Tried","Consumed in Past 1 Year","Consumed in Past 3 Months","Consumed in Past 7 Days"],
        sampleSizes:DairyflatArray,
        bottom1:"S11. In the past 7 days, have you personally consumed < CATEGORY > at home, at a restaurant, during travel or anywhere else?",
        bottom2:"S12. When was the last time you had < CATEGORY CODED ‘NO’ and ‘DON’T REMEMBER’ IN S11>? It could be at home, at a restaurant, during travel or anywhere else?",
        
        btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"SEA H1’25", btm6:" at 95% CI",
        tblB:[DairybaseData[0],DairybaseData[1]],
        table: [
        ["","Q1'25", "Q2'25"],
        [consumptionLabel[0],DairyeverData[0]+'%', DairyeverData[1]+'%'],
        [consumptionLabel[1],Dairyconsumed1YData[0]+'%',Dairyconsumed1YData[1]+'%'],
        [consumptionLabel[2],Dairyconsumed3MData[0]+'%', Dairyconsumed3MData[1]+'%'],
        [consumptionLabel[3],Dairyconsumed7DData[0]+'%', Dairyconsumed7DData[1]+'%'],
        ]
    }];

    ConsumptionFunnelArray.forEach(slideData => {
        slide.addText(slideData.title,opts1);
        slide.addText(slideData.subtitle,opts2);
        slide.addText(slideData.subtitle1,opts3);
        slide.addText("Base – All Respondents",opts3a);
        slide.addText("Base – All Respondents",opts4a);
        slide.addText(slideData.subtitle3,opts4);
        slide.addShape(pptx.ShapeType.line, { x: 0.28,y: 1.20,w: 6.64, h: 0, line: { color: '75b1bb', width: 1.2 } });
        slide.addShape(pptx.ShapeType.line, { "x": 7.31,"y": 1.20,"w": 2.47, h: 0, line: { color: '75b1bb', width: 1.2 } });
        slide.addText(slideData.countries[0],opts5);
        slide.addText(slideData.countries[1],opts6);
        slide.addText(slideData.countries[2],opts7);
        slide.addText(slideData.countries[3],opts8);
        slide.addText(slideData.countries[4],opts9);
        slide.addText(slideData.countries[5],opts10);
        slide.addText(slideData.countries[6],opts11);

        slide.addImage({ x: 2.32,y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[1] });
        slide.addImage({ x: 3.15, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[2] });
        slide.addImage({ x: 3.98, y: 1.43,w: 0.47,h: 0.39, path: slideData.flags[3] });
        slide.addImage({ x: 4.80, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[4] });
        slide.addImage({ x: 5.63, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[5] });
        slide.addImage({ x: 6.42, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[6] });

        slide.addText(slideData.funnel[1],opts12);
        slide.addText(slideData.funnel[2],opts13);
        slide.addText(slideData.funnel[3],opts14);
        slide.addText(slideData.funnel[4],opts15);
        slide.addText(slideData.bottom1,opts16);
        slide.addText(slideData.bottom2,opts17);

        slide.addShape(pptx.ShapeType.rect,opts18);
        slide.addText(slideData.ever[0]+'%',opts18a);

        slide.addShape(pptx.ShapeType.rect,opts19);
        slide.addText(slideData.consumed1[0]+'%',opts19a);
        
        slide.addShape(pptx.ShapeType.rect,opts20);
        slide.addText(slideData.consumed3[0]+'%',opts20a);
        
        slide.addShape(pptx.ShapeType.rect,opts21);
        slide.addText(slideData.consumed7[0]+'%',opts21a);

        slide.addShape(pptx.ShapeType.rect,opts22);
        slide.addText(slideData.ever[1]+'%',opts22a);
        
        slide.addShape(pptx.ShapeType.rect,opts23);
        slide.addText(slideData.consumed1[1]+'%',opts23a);
        
        slide.addShape(pptx.ShapeType.rect,opts24);
        slide.addText(slideData.consumed3[1]+'%',opts24a);
        
        slide.addShape(pptx.ShapeType.rect,opts25);
        slide.addText(slideData.consumed7[1]+'%',opts25a);

        slide.addShape(pptx.ShapeType.rect,opts26);
        slide.addText(slideData.ever[2]+'%',opts26a);
        
        slide.addShape(pptx.ShapeType.rect,opts27);
        slide.addText(slideData.consumed1[2]+'%',opts27a);
        
        slide.addShape(pptx.ShapeType.rect,opts28);
        slide.addText(slideData.consumed3[2]+'%',opts28a);
        
        slide.addShape(pptx.ShapeType.rect,opts29);
        slide.addText(slideData.consumed7[2]+'%',opts29a);

        slide.addShape(pptx.ShapeType.rect,opts30);
        slide.addText(slideData.ever[3]+'%',opts30a);
        
        slide.addShape(pptx.ShapeType.rect,opts31);
        slide.addText(slideData.consumed1[3]+'%',opts31a);
        
        slide.addShape(pptx.ShapeType.rect,opts32);
        slide.addText(slideData.consumed3[3]+'%',opts32a);
        
        slide.addShape(pptx.ShapeType.rect,opts33);
        slide.addText(slideData.consumed7[3]+'%',opts33a);

        slide.addShape(pptx.ShapeType.rect,opts34);
        slide.addText(slideData.ever[4]+'%',opts34a);
        
        slide.addShape(pptx.ShapeType.rect,opts35);
        slide.addText(slideData.consumed1[4]+'%',opts35a);
        
        slide.addShape(pptx.ShapeType.rect,opts36);
        slide.addText(slideData.consumed3[4]+'%',opts36a);
        
        slide.addShape(pptx.ShapeType.rect,opts37);
        slide.addText(slideData.consumed7[4]+'%',opts37a);

        slide.addShape(pptx.ShapeType.rect,opts38);
        slide.addText(slideData.ever[5]+'%',opts38a);
        
        slide.addShape(pptx.ShapeType.rect,opts39);
        slide.addText(slideData.consumed1[5]+'%',opts39a);
        
        slide.addShape(pptx.ShapeType.rect,opts40);
        slide.addText(slideData.consumed3[5]+'%',opts40a);
        
        slide.addShape(pptx.ShapeType.rect,opts41);
        slide.addText(slideData.consumed7[5]+'%',opts41a);

        slide.addShape(pptx.ShapeType.rect,opts42);
        slide.addText(slideData.ever[6]+'%',opts42a);
        
        slide.addShape(pptx.ShapeType.rect,opts43);
        slide.addText(slideData.consumed1[6]+'%',opts43a);
        
        slide.addShape(pptx.ShapeType.rect,opts44);
        slide.addText(slideData.consumed3[6]+'%',opts44a);
        
        slide.addShape(pptx.ShapeType.rect,opts45);
        slide.addText(slideData.consumed7[6]+'%',opts45a);

        slide.addShape(pptx.ShapeType.line, { "x": 0.46,"y": 2.74,"w": 6.64, h: 0, line: { color: 'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, { "x": 0.45,"y": 3.35,"w": 6.64, h: 0, line: { color: 'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, { "x": 0.47,"y": 3.96,"w": 6.64, h: 0, line: { color: 'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, { "x": 1.42,"y": 4.41,"w": 5.50,"h": 0.02, line: { color: '75b1bb', width: 1 } });

        slide.addText("n-"+slideData.sampleSizes[0],opts46);
        slide.addText("n-"+slideData.sampleSizes[1],opts47);
        slide.addText("n-"+slideData.sampleSizes[2],opts48);
        slide.addText("n-"+slideData.sampleSizes[3],opts49);
        slide.addText("n-"+slideData.sampleSizes[4],opts50);
        slide.addText("n-"+slideData.sampleSizes[5],opts51);
        slide.addText("n-"+slideData.sampleSizes[6],opts52);

        slide.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });


        let tableRows = slideData.table.map((row, rowIndex, allRows) =>
            row.map(cell => ({
                text: cell,
                    options: {
                        border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                        ? [false, false, false, false] // No border for first and last row
                        : [false, false, true, false], // Bottom border only
                        borderColor: 'e0e0e0',
                        borderSize: 0.5,
                        fontSize: 8,
                        align: 'center',
                        valign: 'middle'
                    }
            }))
        );

        slide.addTable(tableRows, {"x": 7.30,"y": 1.59,"w": 2.59,"h": 2.98});
        slide.addText("n-"+slideData.tblB[0],opts53);
        slide.addText("n-"+slideData.tblB[1],opts54);

        slide.addText([
            { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
            { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
        ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

        slide.addImage({...logoPosition,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
        slide.addImage({...logoPosition1,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});
        slide.addShape(pptx.ShapeType.line, {x: 7.15,y: 1.20,w: 0.00,h: 3.85,line: {color:'969696',width: 1,dashType: 'dash'}});
    });	
        
    // Slide 2
        var frequencyconsumptioncountryLevel = data['S13_3Country'];
        var frequencyconsumptionquarterLevel = data['S13_3Quarter'];
        var frequencyconsumptionopt=["Everyday","2-3 times a week","Once a week","Once every 2 weeks/Once a month","Once every 2-3 months or Less often"];
        var Q1 = frequencyconsumptionquarterLevel["Q1'25"];
        var Q2 = frequencyconsumptionquarterLevel["Q2'25"];
        const frequencyconsumptionq1= Q1.map(item => item.percentage);
        const frequencyconsumptionq2= Q2.map(item => item.percentage);
        var frequencyconsumptionbaseData = [Q1[0].bCount, Q2[0].bCount];
        const frequencycountryData = {};
        const frequencyconsumption1 = [];
        const frequencyconsumption2 = [];
        const frequencyconsumption3 = [];
        const frequencyconsumption4 = [];
        const frequencyconsumption5 = [];
        const frequencyconsumptionbaseArray = [];

        countryLabel4.forEach(country => {
            if (frequencyconsumptioncountryLevel[country]) {
                frequencycountryData[country] = frequencyconsumptioncountryLevel[country];
            }
        });
                
        for (const country in frequencycountryData) {
            const countryData = frequencycountryData[country];
            frequencyconsumptionbaseArray.push(`n-${countryData[0].bCount}`);
            frequencyconsumption1.push(countryData[0].percentage);
            frequencyconsumption2.push(countryData[1].percentage);
            frequencyconsumption3.push(countryData[2].percentage);
            frequencyconsumption4.push(countryData[3].percentage);
            frequencyconsumption5.push(countryData[4].percentage);
        }

        const frequencyconsumptionArray = [{
            title: "Frequency of Consumption",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: frequencyconsumptionopt,
            f:[frequencyconsumption1,frequencyconsumption2,frequencyconsumption3,frequencyconsumption4,frequencyconsumption5],
            sampleSizes:frequencyconsumptionbaseArray,
            bottom1:"S13. You said you have had < CATEGORY >? recently. How often do you usually have?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"SEA H1’25", btm6:" at 95% CI",
            tblB:[frequencyconsumptionbaseData[0],frequencyconsumptionbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [frequencyconsumptionopt[0],frequencyconsumptionq1[0]+'%', frequencyconsumptionq2[0]+'%'],
                [frequencyconsumptionopt[1],frequencyconsumptionq1[1]+'%',frequencyconsumptionq2[1]+'%'],
                [frequencyconsumptionopt[2],frequencyconsumptionq1[2]+'%',frequencyconsumptionq2[2]+'%'],
                [frequencyconsumptionopt[3],frequencyconsumptionq1[3]+'%',frequencyconsumptionq2[3]+'%'],
                [frequencyconsumptionopt[4],frequencyconsumptionq1[4]+'%',frequencyconsumptionq2[4]+'%'],
            ],
        }];

        frequencyconsumptionArray.forEach(slideData => {
            slide2.addText(slideData.title,opts1_2);
            // slide2.addText(slideData.subtitle,opts2);
            // slide2.addText(slideData.subtitle1,opts3);
            // slide2.addText("Base – Consumed in Past 3 months",opts3a);
            // slide2.addText("Base – Those who consumed in Past 3 months",opts4a);
            // slide2.addText(slideData.subtitle3,opts4);
            // slide2.addShape(pptx.ShapeType.line, { x: 0.28,y: 1.20,w: 6.64, h: 0, line: { color: '75b1bb', width: 1.2 } });
            // slide2.addShape(pptx.ShapeType.line, { "x": 7.31,"y": 1.20,"w": 2.47, h: 0, line: { color: '75b1bb', width: 1.2 } });
            // slide2.addText(slideData.countries[0],{...opts5,x: 1.85});
            // slide2.addText(slideData.countries[1],{...opts6,x: 2.64});
            // slide2.addText(slideData.countries[2],{...opts7,x: 3.43});
            // slide2.addText(slideData.countries[3],{...opts8,x: 4.17});
            // slide2.addText(slideData.countries[4],{...opts9,x: 4.84});
            // slide2.addText(slideData.countries[5],{...opts10,x:5.59});
            // slide2.addText(slideData.countries[6],{...opts11,x: 6.30});
            // slide2.addImage({ x: 2.83,y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[1] });
            // slide2.addImage({ x: 3.58, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[2] });
            // slide2.addImage({ x: 4.33, y: 1.43,w: 0.47,h: 0.39, path: slideData.flags[3] });
            // slide2.addImage({ x: 5.04, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[4] });
            // slide2.addImage({ x: 5.79, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[5] });
            // slide2.addImage({ x: 6.46, y: 1.43,w: 0.39,h: 0.39, path: slideData.flags[6] });

            // const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
            //     name: slideData.funnel[slideData.f.length - 1 - i], 
            //     labels: slideData.sampleSizes,
            //     values: freq,
            // }));
            // let tnpa=[];
            // tnpa = [
            //     {
            //         type: pptx.charts.BAR,
            //         data:chartData ,
            //         options: {
            //             barGrouping: "stacked",
            //         },
            //     },
            // ];
            // slide2.addChart(tnpa, opttnpa);
            // let legendItems = [
            //     { color: '3A5A81', text: 'Everyday' },
            //     { color: '70A6FF', text: '2-3 times a week' },
            //     { color: 'C6E48B', text: 'Once a week' },
            //     { color: '6D8A42', text: 'Once every 2 weeks/ once a month' },
            //     { color: 'F28C28', text: 'Once every 2-3 months or less often' },
            // ];
            // legendItems.forEach((item, index) => {
            //     slide2.addShape(pptx.ShapeType.rect, {
            //         x: 0.2,
            //         y: 2.2 + index * 0.5,  
            //         w: 0.060,
            //         h: 0.060,
            //         fill: { color: item.color },
            //         line: { color: 'FFFFFF' }
            //     });
            //     slide2.addText(item.text, {
            //         x: 0.2,
            //         y: 2.24 + index * 0.5,
            //         fontSize: 7,
            //         color: '000000',
            //         fontFace: 'Arial'
            //     });
            // });

            // slide2.addText(slideData.bottom1,opts16);
            // slide2.addText(slideData.bottom2,opts17);
            // slide2.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

            // let tableRows = slideData.table.map((row, rowIndex, allRows) =>
            //     row.map(cell => ({
            //         text: cell,
            //         options: {
            //             border: (rowIndex === 0 || rowIndex === allRows.length - 1)
            //                 ? [false, false, false, false] // No border for first and last row
            //                 : [false, false, true, false], // Bottom border only
            //             borderColor: 'e0e0e0',
            //             borderSize: 0.5,
            //             fontSize: 8,
            //             align: 'center',
            //             valign: 'middle'
            //         }
            //     }))
            // );
            // slide2.addTable(tableRows, {
            //     "x": 7.30,
            //     "y": 1.59,
            //     "w": 2.59,
            //     "h": 2.98
            // });
            // slide2.addText("n-"+slideData.tblB[0],opts53);
            // slide2.addText("n-"+slideData.tblB[1],opts54);
            // slide2.addText([
            //     { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            //     { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
            //     { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
            //     { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            //     { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
            //     { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
            // ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

            // slide2.addImage({...logoPosition,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
            // slide2.addImage({...logoPosition1,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

            // slide2.addShape(pptx.ShapeType.line, {x: 7.15,y: 1.20,w: 0.00,h: 3.85,line: {color:'969696',width:1,dashType:'dash'}});
        });
        pptx.writeFile({ fileName: "ConsumptionFunnel.pptx" });
}