instructions are in hands-on 5 file
1 Mashing Up Data with PowerPivot* When “Filter, Then Calculate” Does Not Work in DAX Measures This time you need to open the file with the worksheet Sls and have it linked to the PowerPivot window, using Add to Data Model as in the last hands-on assignment. 1. Please create a pivot table first showing the sum of sales by each representative on each date. Now the task is made so easy. However, if you want to compare the sales to the total sales for a month, you need to do some calculation. In DAX, instead of using SUMIFS, you need to use Calculate. Calculate asks for an expression and then one or more filters. For those filters, you are going to use a special function called ALL. ALL says that you want it to look not just at one representative’s sales for a particular date, but all the sales in the table. 2. Suppose you want to see % of Grand Total Sales. You need to create a new measure (Hint: right click on Table1 to select Add Measure) by using =SUM(Sls[Sales])/Calculate(SUM(Sls[Sales]), ALL(Sls)). The pivot table shows that % of Grand Total for Bill’s sales of $851 on June 2, 2011 represents 0.9 percent of the grand total sales. 3. Now you want to calculate how Bill’s $851 sale on June 2 compared to all sales on June 2. The numerator of the DAX measure is =SUM(Sls[Sales]). The denominator is going to be hard. Instead of ALL(Sls), you need to ask for AllExcept(Sls, Sls[Date]). It means go ahead and throw out all the filters except for the Date filter. Keep filtering by date. Please create a new measure, % of Daily Sales, by using the formula 2 =SUM(Sls[Sales])/Calculate(SUM(Sls[Sales]),AllExcept(Sls,Sls[Date])). Bill’s $851 sales is now 25% of the daily sales on June 2, 2011. 4. You can also override the filters by specifying other filters in the Calculate Function. The actual syntax of the Calculate function is Calculate (Expression, [filter 1], [filter 2], [filter 3], ….). Please create a new measure, Amber Sales, to calculate all Amber’s sales. The Calculated Field formula should be =CALCULATE(SUM(Sls[Sales]),Sls[Rep]="Amber"). 5. If Amber is the sales star in the store, perhaps you would want to show everyone’s sales as a percentage of Amber’s Sales. =SUM(Sls[Sales])/Calculate(SUM(Sls[Sales]), Sls[Rep]="Amber") shows sales as a percentage of Amber’s total sales for that day. Please create such a new measure 3 4 Mix in Time Intelligence Functions You can apply many filters in the Calculate function. You can replace the first argument in Calculate with MAX, MIN, AVERAGE, or any function. There are 34 Time Intelligence functions. If you want to calculate a running month to date (MTD) total, you can use the Calculate function and specify a filter of DatesMTD(Sls[Date]). But only for reps that match, use AllExcept(Sls, Sls[Rep]). 1. To show MTD sales for each rep, create a new measure, MTDThisRep, using the formula =Calculate(SUM(Sls[sales]), DatesMTD(Sls[Date]), AllExcept(Sls, Sls[Rep])) 2. You can also use previously defined calculated fields to simplify the calculation for another measure. To get to This Rep’s Percentage of MTD Sales versus all MTD Sales, first, you need to build MTDThisRep (Already exists). Next, you need to build MTDAllRep using Calculate(Sum(Sls[Sales]),DatesMTD(Sls[Date]),All(Sls)). Now you can simply build the formula =Sls[MTDThisRep]/Sls[MTDAllRep] as shown in the Calculated Field Settings image below. Please check a book for a complete list of Time Intelligence Functions 5 3. Save and close your Excel file. Half of your completed data table should look like this: 6 Please make sure that all the data columns are properly formatted, all your created measures are activated (with a check mark in front of each). The Excel 2016 program on my computer is a little wired – Sls is only shown as the data model name, not as the table name in the field list. So far as the linked table name in Power Pivot is Sls, the results should not be affected. Combination Layouts The PivotTable drop-down in the PowerPivot Window offers eight choices: If you plan to convert the pivot table to values to reuse it, choose a flattened pivot table which is only a few clicks along the way. A combination report offers one or more pivot tables or charts. Note that for each chart on your layout, Microsoft inserted a new worksheet to hold the actual pivot table for the chart The following steps show how to replicate the layouts shown in the blogs and press: 7 1. Open the Excel file BlogsAndPress. Link it to PowerPivot Window. (Hint: Please review the section on adding calculated columns using DAX. You have to add two new columns – Month and Year to Table1.) 2. Once you added two columns Month and Year to your linked data table, you need to select Four Chart option from Pivot Table menu in PowerPivot window. 3. Select New Worksheet instead of Existing Worksheet in the dialog box. 4. If it does not work well the first time, choose a location rather than letting them default. Choose a spot on Row 5 of the new worksheet (Sheet1 probably). You can always drag a chart structure to wherever you want on the worksheet later as well. 5. Go back to Power Pivot window and select Four Chart option for Existing Worksheet, but Sheet1 location data should show in the text box. 6. Add as many slicers as possible to the top and left of the chart. 7. Look into the charts image on the next page. Simple bar chart on top of the pie chart shows the values of Year and Month. Since these two variables are on the same level, you need to move them into the same Axis field as shown in the field list. The bars should represent the Count of Source. Feel free to use the cross button to change the chart element and the brush button to change the bar color as you like. 8. The pie chart shows Count of Type values by Source. 9. For Media Type, you need to choose Stacked Area from chart models to use. It is created by selecting Type, Month and Year from the Field list. The formula is Type * Year and Month. Legend of the chart should use Type as well. 10. The last chart uses the Stacked Bar Chart model. Webinar belongs to Type. The 3Rd Party is a Source. Thus, it should be created using Type (on Vertical Axis) by Source (as Values), using Source as legend. You may still need to fine tune each chart to make it look identical to the one in the image. 8 11. Now you are ready to make the data display look better. Make Row 1 very tall, perhaps 270 to 300 points tall. Use Insert, Screenshot to add an interesting graphic to Row 1. 12. Add an interesting graphic below the charts to balance the graphic on top of the charts. 13. Go to file, Options, advanced, Display Options for This Worksheet. Clear the Gridlines check box. If you want to go all out, scroll up and clear the scroll bars, sheet tabs, and formula bars. 14. Minimize the ribbon. 15. Add a fill color behind the whole worksheet. 16. Although the pivot table is active, click on the bounding box around each slicer. Right-click on the border. Select properties. Select Move and /Size with cells. 17. Click away from the pivot table. You’ve reached the end of this long assignment. If you ever changed any data in a table, the changes may not be reflected in the pivot table immediately. However, in the top part of the PowerPivot Field List, you may see a warning message to refresh the relevant pivot table and please do it accordingly. If you see the values shown in a pivot table different from those in a given image, examine the measure(s) used and the relationship between the tables in PowerPivot window. They might be the sources of errors. 9 When you complete this assignment, please save both data files, each using the original file name and your name initials as the new file name (the pattern should be
). Submit both files to the relevant assignment submission dropbox in Learn 9. _______________________ *: This assignment is adapted from Chapter 10 in Pivot Table Data Crunching: Microsoft Excel 2010 written by Bill Jelen, Michael Alexander, 2013, Que Publishing, Indianapolis, IN, USA. Sls DateRepSales 6/1/11Bill148 6/1/11Amber107 6/1/11Amber232 6/1/11Amber73 6/1/11Bill136 6/1/11Dale88 6/1/11Chris49 6/1/11Amber134 6/1/11Bill62 6/1/11Amber202 6/1/11Amber299 6/1/11Amber36 6/2/11Dale82 6/2/11Bill107 6/2/11Bill278 6/2/11Bill37 6/2/11Bill134 6/2/11Chris145 6/2/11Eddy190 6/2/11Amber217 6/2/11Eddy250 6/2/11Amber752 6/2/11Dale218 6/2/11Bill32 6/2/11Eddy109 6/2/11Bill66 6/2/11Bill117 6/2/11Eddy122 6/2/11Amber60 6/2/11Amber65 6/2/11Dale59 6/2/11Chris200 6/2/11Bill80 6/2/11Chris84 6/3/11Chris93 6/3/11Amber185 6/3/11Chris218 6/3/11Eddy149 6/3/11Chris54 6/3/11Amber86 6/3/11Chris251 6/3/11Dale62 6/3/11Amber473 6/3/11Bill115 6/3/11Amber99 6/3/11Bill104 6/3/11Amber86 6/3/11Bill34 6/3/11Dale126 6/3/11Bill285 6/3/11Bill149 6/3/11Amber265 6/3/11Bill78 6/3/11Dale48 6/3/11Eddy146 6/3/11Amber114 6/3/11Chris91 6/3/11Amber136 6/3/11Chris321 6/4/11Bill105 6/4/11Amber99 6/4/11Eddy149 6/4/11Amber198 6/4/11Bill41 6/4/11Bill79 6/4/11Chris212 6/4/11Chris217 6/4/11Bill150 6/4/11Chris37 6/4/11Bill25 6/4/11Chris70 6/4/11Bill45 6/4/11Chris62 6/4/11Amber631 6/4/11Bill87 6/4/11Bill127 6/4/11Amber26 6/4/11Chris253 6/5/11Bill225 6/5/11Amber112 6/5/11Dale137 6/5/11Chris72 6/5/11Eddy44 6/5/11Amber44 6/5/11Bill236 6/5/11Chris410 6/5/11Bill66 6/5/11Bill78 6/5/11Chris40 6/5/11Bill267 6/5/11Amber64 6/5/11Bill25 6/5/11Bill123 6/5/11Eddy54 6/5/11Amber142 6/5/11Amber265 6/5/11Amber140 6/5/11Amber61 6/5/11Amber72 6/5/11Bill284 6/5/11Eddy38 6/5/11Chris56 6/6/11Amber77 6/6/11Amber132 6/6/11Dale90 6/6/11Dale63 6/6/11Amber261 6/6/11Eddy290 6/6/11Amber63 6/6/11Chris37 6/6/11Chris96 6/6/11Chris274 6/6/11Bill111 6/6/11Bill247 6/6/11Bill232 6/6/11Bill396 6/6/11Chris26 6/6/11Bill215 6/6/11Eddy57 6/6/11Chris93 6/7/11Chris146 6/7/11Bill225 6/7/11Amber133 6/7/11Chris243 6/7/11Chris37 6/7/11Amber802 6/7/11Bill38 6/7/11Amber63 6/7/11Bill145 6/7/11Dale73 6/7/11Chris132 6/7/11Eddy37 6/7/11Bill288 6/7/11Dale70 6/7/11Bill26 6/7/11Bill254 6/7/11Amber186 6/8/11Chris646 6/8/11Dale28 6/8/11Amber46 6/8/11Amber101 6/8/11Chris66 6/8/11Dale52 6/8/11Amber227 6/8/11Amber949 6/8/11Bill100 6/8/11Amber81 6/8/11Eddy211 6/8/11Eddy130 6/8/11Amber230 6/8/11Bill50 6/8/11Amber198 6/8/11Chris53 6/8/11Eddy36 6/8/11Eddy136 6/8/11Amber186 6/8/11Bill188 6/9/11Bill27 6/9/11Bill31 6/9/11Amber223 6/9/11Eddy37 6/9/11Amber101 6/9/11Bill37 6/9/11Chris39 6/9/11Amber208 6/9/11Amber138 6/9/11Bill116 6/9/11Dale172 6/9/11Bill139 6/9/11Chris160 6/9/11Bill81 6/9/11Amber190 6/9/11Eddy290 6/9/11Bill213 6/9/11Chris44 6/9/11Eddy207 6/9/11Amber25 6/9/11Amber114 6/9/11Bill144 6/9/11Amber39 6/9/11Chris139 6/9/11Dale150 6/9/11Bill70 6/9/11Chris81 6/10/11Amber203 6/10/11Amber68 6/10/11Chris190 6/10/11Bill100 6/10/11Amber80 6/10/11Chris131 6/10/11Amber33 6/10/11Dale59 6/10/11Dale88 6/10/11Amber169 6/10/11Amber94 6/10/11Amber263 6/10/11Eddy238 6/10/11Dale219 6/10/11Amber84 6/10/11Eddy26 6/10/11Dale141 6/10/11Amber50 6/10/11Eddy143 6/10/11Chris115 6/10/11Bill69 6/10/11Bill32 6/10/11Amber61 6/11/11Bill142 6/11/11Amber69 6/11/11Chris216 6/11/11Amber263 6/11/11Bill103 6/11/11Bill85 6/11/11Dale156 6/11/11Amber61 6/11/11Eddy54 6/11/11Amber162 6/11/11Bill570 6/11/11Chris124 6/11/11Amber150 6/11/11Amber122 6/11/11Chris122 6/11/11Amber101 6/11/11Dale212 6/11/11Amber124 6/11/11Bill267 6/11/11Chris26 6/11/11Amber35 6/11/11Bill30 6/11/11Amber209 6/11/11Dale300 6/11/11Chris112 6/11/11Amber297 6/11/11Amber264 6/11/11Chris102 6/11/11Amber275 6/11/11Eddy253 6/11/11Amber258 6/11/11Amber105 6/12/11Eddy191 6/12/11Bill136 6/12/11Amber129 6/12/11Bill185 6/12/11Amber286 6/12/11Amber140 6/12/11Amber185