{"id":6418,"date":"2023-03-16T12:51:33","date_gmt":"2023-03-16T12:51:33","guid":{"rendered":"https:\/\/www.stl-training.co.uk\/b\/?p=6418"},"modified":"2023-12-30T23:00:54","modified_gmt":"2023-12-30T23:00:54","slug":"power-bi-quick-measures","status":"publish","type":"post","link":"https:\/\/www.stl-training.co.uk\/b\/power-bi-quick-measures\/","title":{"rendered":"Power BI \u2013 Quick Measures"},"content":{"rendered":"<p>Microsoft has prepared Power BI to make it easier for users to perform DAX measures without a lot of <a href=\"https:\/\/www.stl-training.co.uk\/syl\/356\/dax-bi-training-courses-london.html\">DAX<\/a> knowledge.<\/p>\n<p>To access the Quick Measures, click QUICK MEASURES on the Home tab. You will see a list of options to choose from. On the right side of the Quick Measure dialog box, you will find all the tables from your data model.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6419 size-full\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-1.jpg\" alt=\"DAX\" width=\"903\" height=\"645\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-1.jpg 903w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-1-300x214.jpg 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-1-768x549.jpg 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/> <img decoding=\"async\" class=\"alignnone size-medium wp-image-6420\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2-300x66.png\" alt=\"\" width=\"300\" height=\"66\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2-300x66.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2-768x169.png 768w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2.png 902w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<h2>Example 1 \u2013 Rolling Average<\/h2>\n<p>Many use rolling average to smoothing the data set. Unusual periods can be disrupting for understanding patterns and especially in projections, they can make forecasts unnecessarily inaccurate.<\/p>\n<p>In the example below a line chart visualises sales numbers over several years, but a number of periods were unusual and you want the audience to understand how the quantity would look under normal conditions.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6420 size-full\" title=\"DAX\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2.png\" alt=\"DAX\" width=\"902\" height=\"199\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2.png 902w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2-300x66.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-2-768x169.png 768w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><\/p>\n<p>From the dialog box you can select the Quick Measure \u2018Rolling Average\u2019 from the Calculation list. You will now need to add the fields from your tables and set up the parameters.<\/p>\n<p>In this example the quantity is the Base value, Dates are added to the Date field (Rolling Average is a Time Intelligent measure and the primary key from the timetable needs to be added), and Periods before and after are set to 3 months (the smoothing level).<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6421 size-full\" title=\"Measures\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-3.png\" alt=\"Measures\" width=\"903\" height=\"778\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-3.png 903w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-3-300x258.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-3-768x662.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<p>When you click OK Power BI will the write the DAX.<\/p>\n<p>Quantity rolling average\u00a0 =<\/p>\n<p>IF(<\/p>\n<p>ISFILTERED(&#8216;Dates'[Dates]),<\/p>\n<p>ERROR(&#8220;Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.&#8221;),<\/p>\n<p>VAR __LAST_DATE = ENDOFMONTH(&#8216;Dates'[Dates].[Date])<\/p>\n<p>VAR __DATE_PERIOD =<\/p>\n<p>DATESBETWEEN(<\/p>\n<p>&#8216;Dates'[Dates].[Date],<\/p>\n<p>STARTOFMONTH(DATEADD(__LAST_DATE, -3, MONTH)),<\/p>\n<p>ENDOFMONTH(DATEADD(__LAST_DATE, 3, MONTH))<\/p>\n<p>)<\/p>\n<p>RETURN<\/p>\n<p>AVERAGEX(<\/p>\n<p>CALCULATETABLE(<\/p>\n<p>SUMMARIZE(<\/p>\n<p>VALUES(&#8216;Dates&#8217;),<\/p>\n<p>&#8216;Dates'[Dates].[Year],<\/p>\n<p>&#8216;Dates'[Dates].[QuarterNo],<\/p>\n<p>&#8216;Dates'[Dates].[Quarter],<\/p>\n<p>&#8216;Dates'[Dates].[MonthNo],<\/p>\n<p>&#8216;Dates'[Dates].[Month]<\/p>\n<p>),<\/p>\n<p>__DATE_PERIOD<\/p>\n<p>),<\/p>\n<p>CALCULATE(SUM(&#8216;Line_Items'[Quantity]), ALL(&#8216;Dates'[Dates].[Day]))<\/p>\n<p>)<\/p>\n<p>)<\/p>\n<p>&nbsp;<\/p>\n<p>By adding the Rolling Average to the line chart, you can see the result below.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6422 size-full\" title=\"Measures\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-4.png\" alt=\"Measures\" width=\"903\" height=\"507\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-4.png 903w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-4-300x168.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-4-768x431.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<h2>Example 2 \u2013 Percentage difference from filtered value.<\/h2>\n<p>The line chart below (the columns) shows sales in 3 different countries Canada, Mexico, and United States. It shows how much is generated in sales by Canada and Mexico by percentage.<\/p>\n<p>The line is calculated by another Quick Measure &#8211; Percentage difference from filtered value.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6423 size-full\" title=\"Measures\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-5.png\" alt=\"Measures\" width=\"903\" height=\"507\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-5.png 903w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-5-300x168.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-5-768x431.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<p>In this example the Base Value is a sales measure. You can define how you want this quick measure the handle blanks. You can display them as blanks or you can tell the measure to treat blanks as zero. In this example the measure is filtered by country, and we have selected United States.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6424 size-full\" title=\"Measures\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-6.png\" alt=\"Measures\" width=\"902\" height=\"742\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-6.png 902w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-6-300x247.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-6-768x632.png 768w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><\/p>\n<p>And as in the first example Power BI will write the DAX.<\/p>\n<p>sales % difference from U.S.A. =<\/p>\n<p>VAR __BASELINE_VALUE = CALCULATE([sales], &#8216;Customers'[Country] IN { &#8220;U.S.A.&#8221; })<\/p>\n<p>VAR __MEASURE_VALUE = [sales]<\/p>\n<p>RETURN<\/p>\n<p>IF(<\/p>\n<p>NOT ISBLANK(__MEASURE_VALUE),<\/p>\n<p>DIVIDE(__MEASURE_VALUE &#8211; __BASELINE_VALUE, __BASELINE_VALUE)<\/p>\n<p>)<\/p>\n<h2>Example 3 \u2013 Correlation Coefficient<\/h2>\n<p>In this example correlation between product unit prices and sales quantity needs to be investigated. Does the price affect the quantity sold?<\/p>\n<p>The quantity and unit price have been added to a scatter chard below. The trend line will indicate to us the relationship between the two. The dots are spread out. This indicates that there isn\u2019t a close relationship between the two variables, but what is the correlation coefficient?<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6425 size-full\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-7.png\" alt=\"\" width=\"903\" height=\"318\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-7.png 903w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-7-300x106.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-7-768x270.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<p>A Quick Measure can very simply find the result.<\/p>\n<p>Category here is the products identified by the field Product ID. Measure X and Measure Y are the here the sum of quantity and sum of unit price.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6426 size-full\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-8.png\" alt=\"\" width=\"902\" height=\"558\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-8.png 902w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-8-300x186.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-8-768x475.png 768w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><\/p>\n<p>Again, Power BI will write the DAX.<\/p>\n<p>Sum of Unit Price and Quantity correlation for Product ID =<\/p>\n<p>VAR __CORRELATION_TABLE = VALUES(&#8216;Items'[Product ID])<\/p>\n<p>VAR __COUNT =<\/p>\n<p>COUNTX(<\/p>\n<p>KEEPFILTERS(__CORRELATION_TABLE),<\/p>\n<p>CALCULATE(SUM(&#8216;Items'[Unit Price]) * SUM(&#8216;Line_Items'[Quantity]))<\/p>\n<p>)<\/p>\n<p>VAR __SUM_X =<\/p>\n<p>SUMX(<\/p>\n<p>KEEPFILTERS(__CORRELATION_TABLE),<\/p>\n<p>CALCULATE(SUM(&#8216;Items'[Unit Price]))<\/p>\n<p>)<\/p>\n<p>VAR __SUM_Y =<\/p>\n<p>SUMX(<\/p>\n<p>KEEPFILTERS(__CORRELATION_TABLE),<\/p>\n<p>CALCULATE(SUM(&#8216;Line_Items'[Quantity]))<\/p>\n<p>)<\/p>\n<p>VAR __SUM_XY =<\/p>\n<p>SUMX(<\/p>\n<p>KEEPFILTERS(__CORRELATION_TABLE),<\/p>\n<p>CALCULATE(SUM(&#8216;Items'[Unit Price]) * SUM(&#8216;Line_Items'[Quantity]) * 1.)<\/p>\n<p>)<\/p>\n<p>VAR __SUM_X2 =<\/p>\n<p>SUMX(<\/p>\n<p>KEEPFILTERS(__CORRELATION_TABLE),<\/p>\n<p>CALCULATE(SUM(&#8216;Items'[Unit Price]) ^ 2)<\/p>\n<p>)<\/p>\n<p>VAR __SUM_Y2 =<\/p>\n<p>SUMX(<\/p>\n<p>KEEPFILTERS(__CORRELATION_TABLE),<\/p>\n<p>CALCULATE(SUM(&#8216;Line_Items'[Quantity]) ^ 2)<\/p>\n<p>)<\/p>\n<p>RETURN<\/p>\n<p>DIVIDE(<\/p>\n<p>__COUNT * __SUM_XY &#8211; __SUM_X * __SUM_Y * 1.,<\/p>\n<p>SQRT(<\/p>\n<p>(__COUNT * __SUM_X2 &#8211; __SUM_X ^ 2)<\/p>\n<p>* (__COUNT * __SUM_Y2 &#8211; __SUM_Y ^ 2)<\/p>\n<p>)<\/p>\n<p>)<\/p>\n<p>&nbsp;<\/p>\n<p>The correlation between unit price and quantity here is -0.15. In other words when a product gets more expensive the sold quantity decreases. But a negative correlation of -0.15 isn\u2019t much. Nevertheless it could be a clever idea to keep an eye on this number over time to understand the sales pattern.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6427 size-full\" src=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-10.png\" alt=\"\" width=\"903\" height=\"507\" srcset=\"https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-10.png 903w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-10-300x168.png 300w, https:\/\/www.stl-training.co.uk\/b\/wp-content\/uploads\/2023\/03\/DAX-blog-Jens-10-768x431.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>Microsoft has given their clients a shortcut to create DAX measures by offer the quick measure tool. Quite complicated measures can be achieved without prior DAX knowledge.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft has prepared Power BI to make it easier for users to perform DAX measures without a lot of DAX knowledge. To access the Quick Measures, click QUICK MEASURES on the Home tab. You will see a list of options to choose from. On the right side of the Quick Measure dialog box, you will [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[637,23,651,650],"tags":[649],"class_list":["post-6418","post","type-post","status-publish","format-standard","hentry","category-application","category-data-visualisation","category-power-apps","category-power-bi","tag-power-bi"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/6418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/comments?post=6418"}],"version-history":[{"count":2,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/6418\/revisions"}],"predecessor-version":[{"id":6429,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/6418\/revisions\/6429"}],"wp:attachment":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/media?parent=6418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/categories?post=6418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/tags?post=6418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}