Skip to main content
3 of 4
edited tags, adj title
Adam Spriggs
  • 31.1k
  • 6
  • 44
  • 88

Create a simple AMPScript graph

I'm extremely new to using AMPSCRIPT, and wonder if any of you AMPSCRIPT savvies can help me. I am trying to create an AMPSCRIPT inside of an AMPSCRIPT. The point to this HTML is to present the user a graph of his last 5 weeks of stats. If the user doesn’t have stat for 5 weeks but only 4 or 3 or 2 the stat’s graph will present only the weeks he have stat in. In my DE I have a column of flag_weekstart that helps me to determine how many weeks to present in the graph. The 5Total attribute represent the total stat a user has in week number 5 (5weeks ago). I am using this code:

<!--%%[

VAR @5Total
SET @5Total = AttributeValue("5Total")


VAR @weekstart1

IF [flag_weekstart] == "5" THEN
     SET @weekstart1 = '
                    <table width="90%" cellspacing="0" cellpadding="0" align="center">
                 <tr>
                  <td width="20%" style="border-top:3px solid #000000;">
                <span style="font-family:Verdana, Geneva, sans-serif;font-size:14px;color:#5B6770;text-align:center;"><center>Week of<br><span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#5B6770;text-align:center;">Aug 28<br>&nbsp;</span></center>  </span></td>
                  <td width="20%" style="border-top:3px solid #000000;">
                <span style="font-family:Verdana, Geneva, sans-serif;font-size:14px;color:#5B6770;text-align:center;"><center>Week of<br><span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#5B6770;text-align:center;">Sep 04<br>&nbsp;</span></center>  </span></td>
                  <td width="20%" style="border-top:3px solid #000000;">
                <span style="font-family:Verdana, Geneva, sans-serif;font-size:14px;color:#5B6770;text-align:center;"><center>Week of<br><span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#5B6770;text-align:center;">Sep 11<br>&nbsp;</span></center>  </span></td>
                  <td width="20%" style="border-top:3px solid #000000;">
                <span style="font-family:Verdana, Geneva, sans-serif;font-size:14px;color:#5B6770;text-align:center;"><center>Week of<br><span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#5B6770;text-align:center;">Sep 18<br>&nbsp;</span></center>  </span></td>
                  <td width="20%" style="border-top:3px solid #000000;">
                <span style="font-family:Verdana, Geneva, sans-serif;font-size:14px;color:#5B6770;text-align:center;"><center>Week of<br><span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#5B6770;text-align:center;">Sep 25<br>&nbsp;</span></center>  </span></td>
                 </tr>
                </table>

                <table width="90%" cellspacing="0" cellpadding="0" align="center">
                 <tr>
                  <td width="100%" style="border-bottom:1px solid #A3C70D;">
                <span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#A3C70D;text-align:left;"><center>Total Measurements</center></span>  </td>
                 </tr>
                </table>

                <table width="90%" cellspacing="0" cellpadding="0" align="center">
                 <tr>
                   <td width="20%">
                <span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#A3C70D;text-align:left;"><center>%%=v(@5Total)=%%<br>&nbsp;</center></span>  </td>
                   <td width="20%">
                <span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#A3C70D;text-align:left;"><center>%%4Total%%<br>&nbsp;</center></span> </td>
                   <td width="20%">
                <span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#A3C70D;text-align:left;"><center>%%3Total%%<br>&nbsp;</center></span>  </td>
                   <td width="20%">
                <span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#A3C70D;text-align:left;"><center>%%2Total%%<br>&nbsp;</center></span>  </td>
                   <td width="20%">
                <span style="font-weight:bold;font-family:Verdana, Geneva, sans-serif;font-size:18px;color:#A3C70D;text-align:left;"><center>%%1Total%%<br>&nbsp;</center></span>  </td>
                 </tr>
                </table>

The code is continuing with: IF [flag_weekstart] == "4" THEN … Until 1.

I tried puling the 5Total attribute using %%=v(@5Total)=%% and %%5Total%% with no luck.

The value I am getting is %%5Total%% like the AMPSCRIPT doesn’t know from where to pull the data from.

Any ideas?