Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

3/31/2017 ExcelChartsInteractiveTotals

(http://www.contextures.com/index.html)

Excel Interactive Totals Chart


ShowtotalsinaninteractiveExcelchart,andusecheckboxesanddropdownliststoshowandhidedata.Getthefreeworkbook.

LONDON
YOUBELONGHERE.Booknowfrom3300/night.
airbnb.co.in

Introduction

WorkbookSetup

StarttheDashboard

AddtheAdmin_ListsSheet

AddtheDashboardCriteria

AddtheChart_DataSheet

LinkCheckBoxestoCells

AddFilterFormulasforData

GetMonthStartDates

AddFormulasforChartData

AddNamesforChartData

CreateaColumnChart

AddDynamicRangestoChart

TesttheRevisedChart

CreateaDashboardTitle

CreateaChartTitle

AddCriteriaLabelsonChart

TesttheInteractiveOnlineChart

DownloadtheWorkbook

MoreChartTutorials

http://www.contextures.com/excelchartsinteractivetotals.html
Introduction 1/23
3/31/2017 ExcelChartsInteractiveTotals

Introduction
Inthisinteractivechart,enteradatarangeonthedashboardsheet,selectcriteriafromtheRangeandCategorylists,thenclickthe
QuantityandPricecheckboxes,tocontrolwhichdataisshowninthechart.Thereisnoprogrammingrequired,justformulas.

Thistechniqueworksbestforsmalltomidsizedtables.Formulasareaddedtothedatatable,sotheworkbookwillslowdownifyou
havethousandsofrowsofdata.

The Workbook Setup


Therearefourworksheetsinthecompletedworkbook:

Dashboard
Sales_Data
Admin_Lists
Chart_Data

Belowisabriefdescriptionofeachsheet,andtheformulasareexplainedinthenextsection.

Dashboard Sheet
Thissheethastheinteractivechart,checkboxestoshoworhidetheQuantityandPrice,andcellsforthedaterangeandcriteria.

ThereisaformulaincellB1,tocalculateacharttitle,basedonthestartandenddates.

http://www.contextures.com/excelchartsinteractivetotals.html 2/23
3/31/2017 ExcelChartsInteractiveTotals

Sales_Data Sheet
ThissheethasanamedExceltabletblSaleswithsalesorderdata.IncolumnsAtoEthereissalesdata,butnoformulas.For
eachsalesorder,wehaveanorderdate,region,category,quantityandtotalsaleprice.

NOTE:The"DataOnly"workbookhasthissheet,withthedatacolumns,andnoformulas.ItdoesnothavetheDashboard,
Admin_ListsorChart_Datasheets.

Inthecompletedworkbook,thereareformulasincolumnsFtoL,tocreatevaluesfortheinteractivechart.

http://www.contextures.com/excelchartsinteractivetotals.html
Admin_Lists Sheet 3/23
3/31/2017 ExcelChartsInteractiveTotals

Admin_Lists Sheet
Thissheethasatwolists,innamedrangesRegionListandCatList.Thoselistsareusedtocreatedropdownlistsforcriteria,onthe
dashboard.

Therearetwocellswithformulas,andthosecellsarealsonamed:StartYrMthandEndYrMth.

Chart_Data Sheet
Thissheethaslinkstothecheckboxes,andformulastocalculatethedaterangeandthetotalamountsforthechart.Dynamicnamed
rangesaredefined,andusedinthechartseries.

Start the Dashboard Sheet


Ifyouarestartingfromscratch,followthesestepstocreatethedashboardsheet:

1.Insertanewsheet,andnameitDashboard
2.Typeheadingsforthecriteriacells:
B3:StartDate
D3:EndDate
F3:Region
H3:Category
3.Toidentifythecriteriaentrycells,formatcellsB4,D4,F4andH4withlightgreenfillandaborder
4.Makethecolumnsbetweenthegreencellsnarrower

http://www.contextures.com/excelchartsinteractivetotals.html 4/23
3/31/2017 ExcelChartsInteractiveTotals

Name the Criteria Cells


Next,nameeachofthegreencriteriacells.(Selectthecell,clickintheNameBox,attheleftoftheformulabar,typeaoneword
name,thenpressEnter)

Later,you'llusethesenamesinformulas:

B4:StartDate

D4:EndDate

F4:SelReg

H4:SelCat

Add the Check Boxes


Next,you'lladdtwocheckboxes,forQuantityandPrice.Whentheboxischecked,itsdatawillappearinthechart.Toaddacheck
box:

1.OntheRibbon,clicktheDevelopertab.(Ifthetabisnotvisible,followtheinstructionshere,toaddtheDevelopertab
(http://www.contextures.com/xlfaqMac.html#developer))
2.ClicktheInsertcommand,andintheFormControlssection,clicktheCheckBox

3.Ontheworksheet,clickincellC6,toaddacheckbox.
4.Rightclickthecheckbox,andclickEditText,thendeletethecaptiontext.
5.Makethecheckboxnarrower,tofitincolumnC.

http://www.contextures.com/excelchartsinteractivetotals.html 5/23
3/31/2017 ExcelChartsInteractiveTotals

6.Rightclickthecheckbox,andclickCopy,thenpasteincellE6.
7.IncellD6,typeQuantityandincellF6,typePrice.
8.GototheViewtabontheExcelRibbon,andturnoffthegridlines.

NOTE:Youcouldadddatavalidationinthestartdateandenddatecells,toensurethatvaliddatesareentered,andtheenddateis
onorafterthestartdate.

Add the Admin_Lists Sheet


Next,followthesestepstocreatetheAdmin_Listssheet:

1.Insertanewsheet,andnameitAdmin_Lists
2.TypeheadingsfortheNamedRanges:
B1:Region
D1:Category
F1:StartYrMth
F4:EndYrMth
3.IncellsB2:B3,typetheregionnames:East,West
4.IncellsD2:D5,typethecategorynames:Snacks,Cookies,Bars,Crackers
5.NamecellsB2:B3asRegionList
6.NamecellsD2:D5asCatList
7.NamecellF2asStartYrMth
8.NamecellF5asEndYrMth

http://www.contextures.com/excelchartsinteractivetotals.html 6/23
3/31/2017 ExcelChartsInteractiveTotals

Add the Dashboard Criteria


Next,followthesestepstoadddropdownlistsintheRegionandCategorycriteriacellsonthedashboardsheet.Thedropdownlists
arecreatedwiththeDataValidationfeature(http://www.contextures.com/xlDataVal01.html).

Region List
TocreateaRegiondropdownlist:

1.OntheDashboardsheet,selectcellF4
2.OntheRibbon,clicktheDatatab,andclickDataValidation
3.FromtheAllowdropdown,selectList
4.ClickintheSourcebox,andpresstheF3key,toseealistofnamedranges
5.ClickonRegionList,thenclickOK
6.ClickOK,tocompletethedropdownlistofregions

Category List
TocreateaCategorydropdownlist:

1.OntheDashboardsheet,selectcellH4
2.OntheRibbon,clicktheDatatab,andclickDataValidation
3.FromtheAllowdropdown,selectList

http://www.contextures.com/excelchartsinteractivetotals.html 7/23
3/31/2017 ExcelChartsInteractiveTotals

4.ClickintheSourcebox,andpresstheF3key,toseealistofnamedranges
5.ClickonCatList,thenclickOK
6.ClickOK,tocompletethedropdownlistofcategories

Enter the Test Criteria


Tosetupsomecriteriafortesting,enterthefollowingdatesontheDashboard:

StartDate:March1,2015
EndDate:June30,2015

Next,fillintheothertwocriteriacells:

ClickthearrowintheRegioncell(F4),andselectEast
SelectCookiesasthecategoryfromthedropdownlistincellH4

Add the Chart_Data Sheet


Next,followthesestepstocreatetheChart_Datasheet:

1.Insertanewsheet,andnameitChart_Data
2.Typeheadingsforthechartdata:
B3:ID
C3:DateRange
D3:Quantity
E3:Price
F3:MthEnd
3.IncellsB4:B39,makealistofnumbers,from1to36foramaximumof3yearsofdata
4.Toidentifythechartdatacells,selectcellsB3:F39andapplyan"AllBorders"border
5.Also,addborderstocellsD2andE2thesecellswillbelinkedtothecheckboxesonthedashboard
6.NamecellD2asLinkQty,andnamecellE2asLinkPrice

http://www.contextures.com/excelchartsinteractivetotals.html 8/23
3/31/2017 ExcelChartsInteractiveTotals

Link Check Boxes to Cells


ThenextstepistoconnectthedashboardcheckboxestothecellsontheChart_Datasheet.

1.OntheDashboardsheet,rightclickontheQuantitycheckbox,andclickFormatControl
2.ClickintheCellLinkbox,andtypeLinkQtythenameofthelinkedcellontheChart_Datasheet.
3.ClickOKtoclosetheFormatControlwindow

4.ClickOKtoclosetheFormatControlwindow.
5.Next,rightclickthePricecheckbox,andlinkittotheLinkPricecell.

Totestthelinkedcells:

1.Clickeachofthecheckboxes,toremovethecheckmark,ifithasone
2.GototheChart_Datasheet,andeachofthelinkedcellsshouldcontain"FALSE".
3.GobacktotheDashboard,andaddacheckmarkineachcheckbox
4.NowthelinkedcellsontheChart_Datasheet,shouldcontain"TRUE".

NOTE:Ifyouclearthosecells,ortypeFALSE,itwillalsoclearthecheckboxes.

http://www.contextures.com/excelchartsinteractivetotals.html 9/23
3/31/2017 ExcelChartsInteractiveTotals

Add Filter Formulas for Data


Next,youwilladdcolumnswithformulasonthedatasheet,tocheckeachrecordfortheselecteddaterange,regionandcategory.

Add Filter Column Headings


1.OntheDatasheet,addthefollowingheadingsincellsI1:N1SelDate,SelReg,SelCat,AllOK,CalcQty,CalcPrice.Thetablewill
expandautomaticallytoincludethenewheadings.
2.(optional)Colourtheheadingcells,sotheystandoutfromtheotherheadings

Add Filter Column Formulas


OntheDatasheet,addthefollowingformulasinthefiltercolumns.Theformulasareenteredinthefirstdatarow,andwillfilldown
automatically.
Test the 3 Criteria
Thefirstthreeformulascheckthecriteria,andreturnTRUEorFALSE.Thetwominussigns(doubleunary)atthestartofthe
formulachangeTRUEto1andchangeFALSEto0.

CellI2,tocheckiftherecordisintheselecteddaterange

=AND([@OrderDate]>=StartDate,[@OrderDate]<=EndDate)

CellJ2,tocheckiftherecordisintheselectedRegion,ornoRegionwasselected

=OR([@Region]=SelReg,SelReg="")

CellK2,tocheckiftherecordisintheselectedCategory,ornoCategorywasselected

=OR([@Category]=SelCat,SelCat="")
Are All 3 Criteria TRUE?
IncellL2,theformulacheckstoseeifall3criteriatestsareTRUE.Ifso,theSumthosecellswillbe3,whichmatchestheCountof
thosecells.

=(SUM(Sales_Data[@[SelDates]:[SelCat]])=COUNT(Sales_Data[@[SelDates]:[SelCat]]))

Theresultwillbe1ifallcriteriaareTRUE,and0ifnotallareTRUE.
Calculate the Quantity and Price
Inthefinaltwocolumns,theoriginalquantityandpricearemultipliedbythe1or0incolumnL.So,ifall3criteriaareTRUE,the
originalquantityandpricearereturned,otherwisetheresultis0.

CellM2,tocalculatetheQuantitybasedonselectedcriteria:

=[@Quantity]*[@AllOK]

http://www.contextures.com/excelchartsinteractivetotals.html 10/23
3/31/2017 ExcelChartsInteractiveTotals

CellN2,tocalculatethePricebasedonselectedcriteria:

=[@SalePrice]*[@AllOK]

Check the Results


Toseetheformularesults,scrolldowntheDatasheettorow92.Thatordermeetsallthreecriteria:

1.OrderDateisinthedaterangeyouenteredontheDashboard.
2.RegionisEast
3.CategoryisCookie

BecauseallthreecriteriawereTRUE,thereisa1intheAllOKcolumn(L),andtheCalcQtyandCalcPricecolumnshowtheoriginal
amounts.

Get Month Start Dates


Tocreatethechart,you'llbeshowingatotalforeachmonthinthedaterange.Togetthefirstdateinthestartandendmonths,add
thefollowingformulasontheListssheet:

G2:=EOMONTH(StartDate,1)+1

G3:=EOMONTH(EndDate,1)+1

TheEOMONTHfunctiongetsthelastdateinamonth,basedonastartingdate,andoffsetbyaspecifiednumberofmonths.

IntheformulaincellG3:

thestartingdateisthevalueintheEndDatecell
thenumberofmonthsis1

OurenddateisJune30,2015,sothelastdayofthemonthbeforethatisMay31,2015

Then,theformulaadds1tothatdate,togetthefirstdayofthenextmonthJune1,2015.

http://www.contextures.com/excelchartsinteractivetotals.html 11/23
3/31/2017 ExcelChartsInteractiveTotals

Add Formulas for Chart Data


Tocreatethechart,you'llbeshowingatotalforeachmonthinthedaterange.Thiswillbedonewithformulasthatchecktheselected
criteria,andthecellsthatarelinkedtothecheckboxes.

GototheChart_Datasheet,andenterthefollowingformulas,tocalculatethedatesandquantitiesforthechartdata.

1.CellC4:=IF(StartYrMth="","",IF(B4=1,StartYrMth,IF(F3<EndDate,F3+1,"")))
2.CellD4:=IF($C4="","",IF(D$2=FALSE,NA(),SUMIFS(Sales_Data[CalcQty],Sales_Data[YrMth],C4)))
3.CellE4:=IF($C4="","",IF(E$2=FALSE,NA(),SUMIFS(Sales_Data[CalcPrice],Sales_Data[YrMth],C4)))
4.CellF4:=IF(C4="","",EDATE(C4,1)1)

Next,copyallfourformulasdowntotheendofthelist,inrow39.

The Formula Results


BasedonthecriteriaandcheckboxselectionsontheDashboardsheet,alistofdatesandamountswillappearintheformulacells

Dates:TheDateRangecolumn(C)showsalistofmonthstartingdates,forallthemonthsintheselecteddaterange.
Quantity:IfD2isTRUE,thetotalquantityforeachmonthisshown,basedontheamountsintheCalcQtycolumnontheData
sheet.
Price:IfE2isTRUE,thetotalpriceforeachmonthisshown,basedontheamountsintheCalcPricecolumnontheDatasheet.
MonthEnd:TheMthEndcolumn(F)showsthemonthenddates,forallthemonthsintheselecteddaterange.

Remove a Check Mark


IfyouremovethecheckmarkforQuantityorPriceontheDashboardsheet,thatcolumnshows#N/A,andthosevalueswon'tbe
shownonthechart.

http://www.contextures.com/excelchartsinteractivetotals.html 12/23
3/31/2017 ExcelChartsInteractiveTotals

Add Names for Chart Data


NextyouwillcreatesomenamedrangesontheChart_Datasheet.Thesenameswillallowyoutobuildaflexiblechart,basedonthe
rowsthathavetotalsshowing,andignoringtheotherrows.

Static Named Ranges


First,createthefollowingtwonamedrangesthesearestaticranges,sotheywon'tadjustwiththedata.

SelectcellC3,andnameitasChartStart
SelectcellsC4:C39,andnamethatrangeasChartDatesALL

Dynamic Named Ranges


Next,youwillcreatedynamicrangesthesewilladjustwiththedata.
The ChartData Range
Thefirstdynamicrangewillcontainallthechartdata.Todefinetherange,followthesesteps:

1.OntheExcelRibbon,gototheFormulastab,andclickDefineName
2.IntheNamebox,enter:ChartData
3.IntheRefersTobox,typethisformula:=OFFSET(ChartStart,1,0,COUNT(ChartDatesALL),3)
4.ClickOKtocompletethename

TheformulausestheOFFSETfunction(http://www.contextures.com/exceloffsetfunction.html)tocreateareference:

ThisrangestartsincellC4,whichisonerowbelowtheChartStartcell.
ThenumberofrowsintherangeisbasedonthecountofdatesintheChartDatesALLrange
Thereare3columnsintherange,fortheDate,QuantityandPrice

ToseethecurrentrangeforChartData:

1.OntheExcelRibbon,gototheFormulastab,andclickNameManager
2.Inthelistofnames,clickonChartData
3.ClickintheRefersTobox,wheretheformulais
4.OntheChart_Datasheet,thecellsintheChartDatarangewillbeoutlinedwith"marchingants"(ascrollingmarquee)

http://www.contextures.com/excelchartsinteractivetotals.html 13/23
3/31/2017 ExcelChartsInteractiveTotals

Three More Dynamic Ranges


Next,youwillcreatethreemoredynamicrange,fortheDate,PriceandQuantitydata.TheserangeswillbeoffsetfromtheChartData
rangethatyoucreatedinthepreviousstep.

Followthesamestepstodefinethese3names:

1.Name:ChartDatesFormula:=OFFSET(ChartData,,0,,1)
2.Name:ChartQtyFormula:=OFFSET(ChartData,,1,,1)
3.Name:ChartPriceFormula:=OFFSET(ChartData,,2,,1)

StartingfromtheChartDatarange:

theChartDaterangemoves0columnstotherightitstartsinthesamecolumnastheChartDatarange.
theChartQtyrangeis1columntotheright
theChartPricerangeis2columnstotheright.

Allthreerangeshaveawidthof1column,insteadofthe3columnsinChartData.

Create a Column Chart


Next,you'llcreateacolumnchart,basedonthedatathatiscurrentlyvisibleontheChart_Datasheet:

1.OntheChart_Datasheet,selectthevisibledataandheadingsinthetablecellsC3:E7
2.OntheRibbon,clicktheInserttab
3.ClicktheColumnChartcommand,thenclick2DClusteredColumnchart

http://www.contextures.com/excelchartsinteractivetotals.html 14/23
3/31/2017 ExcelChartsInteractiveTotals

4.Cutthechart,andpasteitontotheDashboardsheet.

Test the Interactive Chart


Currently,thisisastaticchart,soitwillonlyshow4monthsofdata,evenifyouchangethedaterange.Youwilladjustthechart
later,soitusesthedynamicrangesthatyoucreated.

However,theothercriteriawillworkcorrectly,soyoucantestthose:

ClickonthethePricecheckboxes,toaddacheckmark.ThePricecolumnswillappearinthechart
ChangetheRegiontoWest,toseetheCookiessalesinthatregion.
ChangetheCategorytoBars,toseetheBarssalesintheWestregion.

http://www.contextures.com/excelchartsinteractivetotals.html 15/23
3/31/2017 ExcelChartsInteractiveTotals

Add Dynamic Ranges to Chart


Next,you'lladjustthechart,soitusesthedynamicrangesthatyoucreated.

Change the Chart Data Range


First,you'llsetthechartsourcedatatothedynamicrange,ChartData.

1.Clickthechart,toselectit
2.OntheRibbon,underChartTools,clicktheDesigntab
3.ClicktheSelectDatacommand

4.IntheChartDataRangebox,youwillseetheexistingformula,withitsstaticreferences:
=Chart_Data!$C$3:$E$7

http://www.contextures.com/excelchartsinteractivetotals.html 16/23
3/31/2017 ExcelChartsInteractiveTotals

5.Changetheformula,toreplacethecellreferenceswithrangenames:
=Chart_Data!ChartData

Change the Quantity Series


Next,you'llsetthedatafortheQuantityseries.

1.IntheLegendEntrieslist,clickonSeries1(previouslyQuantity)
2.ClicktheEditbutton,toopentheEditSerieswindow.
3.ClickintheSeriesNamebox,thengototheChart_Datasheet,andclickoncellD3.
4.IntheSeriesValuesbox,changetheformula,toreplacethecellreferenceswiththerangename:
=Chart_Data!ChartQty

5.ClickOK.

http://www.contextures.com/excelchartsinteractivetotals.html 17/23
3/31/2017 ExcelChartsInteractiveTotals

Change the Price Series


Next,you'llsetthedataforthePriceseries.

1.IntheLegendEntrieslist,clickonSeries2(previouslyPrice)
2.ClicktheEditbutton,toopentheEditSerieswindow.
3.ClickintheSeriesNamebox,thengototheChart_Datasheet,andclickoncellE3.
4.IntheSeriesValuesbox,changetheformula,toreplacethecellreferenceswiththerangename:
=Chart_Data!ChartPrice

5.ClickOK.

http://www.contextures.com/excelchartsinteractivetotals.html Change the Date Labels 18/23


3/31/2017 ExcelChartsInteractiveTotals

Change the Date Labels


Thefinalstepistoeditthedatereferences.

1.IntheSelectDataSourcewindow,intheHorizontal(Category)AxisLabelssection,clicktheEditbutton.
2.IntheAxisLabelswindow,changetheAxisLabelRange,replacingthecellreferenceswiththeChartDatesnamedrange:
=Chart_Data!ChartDates

3.ClickOK,toclosetheAxisLabelswindow,thenclickOKtoclosetheSelectDataSourcewindow.

Test the Revised Chart


Nowthatthedynamicrangeshavebeenadded,youcantestthedaterangesettings,toseeifthenumberofmonthsinthechart
changes..

Totestthedates:

ChangetheEndDateto5/31/15thechartshouldchange,toshowonly3months.
ChangetheEndDateto8/31/15thechartshouldchange,toshow6monthsofdata.

Create a Dashboard Title


Tofinishthedashboard,you'lladdaformulaatthetop,toshowatitlethatincludestheselecteddaterange.

PasteinthefollowingformulaintocellB1:
="Sales:"&TEXT(StartDate,"ddmmmyyyy")&"to"&TEXT(EndDate,"ddmmmyyyy")
FormatcellB1inalarge,boldfont.Inthescreenshotbelow,Calibri14Boldisused.

http://www.contextures.com/excelchartsinteractivetotals.html 19/23
3/31/2017 ExcelChartsInteractiveTotals

Create a Chart Title


Next,youwilllinkthechart'stitletothedashboardtitle,soitalsoshowstheselecteddaterange.

Tolinkthecharttitletothedashboardtitle:

1.Clickonthechart'stitle,toselectit.
2.ClickintheFormulabar,andtypeanEqualSign(=)
3.ClickoncellB1,whichcontainsthedashboardtitle
4.PressEnter,tocompletetheformula

Thecharttitlewillchangefromthedefault"ChartTitle",andwillshowtheresultoftheformulaincellB1.

Youcanformatthecharttitle,ifyouwantadifferentfontorsize.

http://www.contextures.com/excelchartsinteractivetotals.html 20/23
3/31/2017 ExcelChartsInteractiveTotals

Add Criteria Labels on Chart


Asaoptionalstep,youcanalsoshowtheselectedcriteriaonthechart,byaddingtextboxesthatarelinkedtothecriteriacells.This
wouldbehelpfulifyoumovethecharttoadifferentsheet,orwanttoprintthechartseparately.

Toshowthecriteria,followthesesteps:

1.Clickonthecharttoselectit.
2.OntheRibbon'sInserttab,clicktheTextBoxcommand
3.Inanemptypartofthechart,dragtocreateasmalltextboxjustbigenoughtoshowtheregionname

4.ClickintheFormulabar,andtypeanEqualSign(=)
5.ClickoncellF4,whichcontainstheRegionname
6.PressEnter,tocompletetheformula

Repeatthesteps,toaddatextboxwiththeCategoryname,linkedtocellH4.

Then,movethetextboxes,orresizethem,ifnecessary.

Inthescreenshotbelow,Iaddedspacebelowthecharttitle,andmovethetextboxesthere.

http://www.contextures.com/excelchartsinteractivetotals.html
Download the Workbooks 21/23

You might also like