I am just bursting with excitement!! This month the amazing Power BI team has yet again come out with a great new feature, Icon sets. In addition to this you can enhance these icon sets by adding your own custom icons to your Power BI reports. Woo Hoo….
So what does this mean? Well, now you have a new Conditional Formatting box found in the settings of the Table and the Matrix properties. To use a built in Icon from Power BI. Create either a table or a Matrix visual with some data.
Select the visual and adjust it’s properties by clicking on the Paint Roller and opening the Conditional Formatting window.
Scroll down until you see the toggle button for Icons. Turn the Icons On.
Click on the Advanced Controls to set the properties of the icons based on the data properties. This type of dialog box should look familiar as it is similar to the previous boxes for conditional formatting. Opening this window shows Icons for each Rule in the list. To adjust an icon Click on the Drop DownArrow next to the icon you wish to change. There are multiple icons to choose from.
There are limited selections by default, but you can enhance this by adding your own icons with the custom Json theme files. At PowerBI.tips we love our theme files. They make using standard settings so much easier.
Loading the Custom Icons
For starters we have already done the hard work of creating an additional 50 icons for you to use in your reports. Download the Icon Theme File Here
Update: Special thanks to Reid Havens from Havens Consulting for contributing extra icons to this Icon Set.
Unzip the downloaded file to find the PowerBITips Icons v1.json file
Navigate to the Home ribbon in Power BI Desktop
Click on the Switch Theme button
Select the list item Import Theme from the drop down menu
The open file dialog box will open. Select the PowerBITips Icons v1.json file that you downloaded earlier.
Boom, and just like that you have loaded your new icons. Now you can return to the icons for your table or matrix and adjust until your heart is content.
Here is a sample of a table and a matrix with some custom icons applied:
Update 2019/08/06: When publishing the Power BI file to the PowerBI.com service, the fill colors for the shapes need to have a %23 instead of a # (HASH) infront of the HEX codes. Thus, the format should look like fill=’%23FF0000′ instead of fill=’#FF0000′
If you like the content from PowerBI.Tips please follow us on all the social outlets. Stay up to date on all the latest features and free tutorials. Subscribe to our YouTube Channel. Or follow us on the social channels, Twitter and LinkedIn where we will post all the announcements for new tutorials and content.
Introducing our PowerBI.tips SWAG store. Check out all the fun PowerBI.tips clothing and products:
Time and time again when I begin talking with Excel users and ask to see what current reports they are using, they usually show me a table with a mixed bag of columns split by different time ranges. A comparison of month over month, or year over year, mixed in with a few daily totals or cumulative totals all rolled up from values on other tabs to produce their preferred view (or dashboard). Typically, the first approach I take is to describe how we can break up this single table view of things and start looking at the aggregations of these values in easily digestible pieces and slice and dice them in different times ranges. I’ve explained that the goal should be to produce easy to consume visuals for comparison using measures and plotting these out in different ways to glean insights quicker. Most of the time, this works, but other times… it is second best to what the analyst or uber Excel user wants to see… they want to see their numbers, and they want to see them the same way they have them in Excel.
The Challenge:
Recently, I encountered this all
too familiar scenario (Time Ranges in a table/matrix) except this time, I
wanted to see if I could reproduce the output exactly as the end user wanted it
rather than move them in a different direction.
The first group of columns showed
the days in the current week, the second group showed the weeks in the current
month, followed by the Months to date, a year to date column and static columns
of a Goal and Forecast.
I’ll spare you the details of
researching a better way than producing these as individual measures, and suffice to say that I was able to come up
with a solution based on a few calculated columns, a disassociated table, and a
single measure to produce the output I was searching for.
The Solution:
The above screenshot is of the
dynamic matrix that you can download from the link at the end of this blog. As
I developed this solution it came to my attention that there are actually a
couple ways we could build this solution. The first of those would be to have a
time slicer drive all the different time ranges, this would be useful for analyzing
older datasets in the different ranges, but my goal was to create a solution
that follows the “Set it and forget it” train of thought. This solution will
restrict the view of data to never exceed the current day, the neat thing is,
the current day is when you read this blog, not a static point in time. I’ve
pre-loaded data out to the end of 2020, so the sample should continue to work
and change each time the file is opened.
Before we dig into things, I want to convey that the DAX dove a bit deeper into the weeds than I initially expected, and I’ll do my best to describe what I did and why.
The Data
I’ve modified my original solution
to use a sample of Adventure works data that I created, this simple dataset
consists of a column to group things by (ModelName), a date (StartDate) and the
value to aggregate (ListPrice). This solution should cover a wide range of
different use cases so don’t get hung up on the exact columns here. A grouping
column, a date column and a value column are all you need.
Here are the steps I took after creating the dataset and loading it into Excel:
Load Data table from Excel into Power Query, Close & Apply
Create a calculated date table (DAX):
Date =
VAR MinYear = 2018
VAR MaxYear = 2020
RETURN
ADDCOLUMNS (
FILTER (
CALENDARAUTO( ),
AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )
),
"Calendar Year", YEAR ( [Date] ),
"Month Name", FORMAT ( [Date], "mmmm" ),
"Month Number", MONTH ( [Date] ),
"Weekday", FORMAT ( [Date], "dddd" ),
"Week Number", WEEKNUM([Date]),
"Weekday number", WEEKDAY( [Date] ),
"Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1
)
Your MinYear / MaxYear will obviously be different, but the core columns for what we need are in this output.
Add Calculated Columns
Now we need to add some filter columns to the date table we just created in order to get the current time frames we care about.
This is our grouping
table, this is the first key element in which we create a series of different
DAX calculated tables to create the different time range groups we want to roll
up our aggregate amount by. In each case, we are pulling all current and
previous years, the current months in this year to date, the current weeks in
the current month and the current days in the week. Then we union those values
together where the “Group” is the top level time range, and the value is the
specific time range values. Then we add an index column so that we can order
the values in the way that we want.
The final output
should look something like this:
This
is the DAX code to create the calculated table. Each “Summarize” creates the time
groups and values rolled up for the particular time range we are interested in.
This is wrapped in the “AddColumns” function to add in a workable index that
allows us to order all the values in the correct order dynamically. Initially,
the static Index column works to sort the Group column, but the dates won’t
sort as Calendar dates so I added the second way to dynamically generate an
index to sort the values by. I retain the original Index value and ensure the
counts returned from the date table align in sequential order. Essentially
retaining the Group/Value index to sort by. Then we wrap all that in “SelectColumns”
so that we can specify the column names. If we didn’t do this, the first column
name would be “Calendar Year”.
Create a relationship between the Date table and the Data Table
This would be on
‘Date’[Date] and ‘Data’[StartDate]
Create our Measures
Now we need to take
the grouping table and merge it with the aggregated value via our measures. In
the Data table we want to create the following measures.
First Measure:
List Price = SUM(Data[ListPrice])
Second Measure:
TimeValue =
VAR Val =
SWITCH(SELECTEDVALUE('TimeRange'[Group]),
"By Year", CALCULATE(TOTALYTD([List Price], 'Date'[Date], FILTER('Date', 'Date'[Date]<= TODAY())), FILTER('Date', 'Date'[Calendar Year] = VALUE(MAX('TimeRange'[Value])))),
"By Month", CALCULATE(TOTALMTD([List Price], 'Date'[Date], FILTER('Date', 'Date'[Date]<= TODAY())), FILTER('Date', 'Date'[Month Number] = VALUE(MAX('TimeRange'[Value])) && 'Date'[Calendar Year] = YEAR(NOW()))),
"By Week", CALCULATE(SUM(Data[ListPrice]), FILTER('Date', 'Date'[Week Number] = VALUE(MAX('TimeRange'[Value])) && 'Date'[Calendar Year] = YEAR(NOW()) && 'Date'[Date]<= TODAY())),
"By Day", CALCULATE(SUM(Data[ListPrice]), FILTER('Date', 'Date'[Date] = DATEVALUE(MAX('TimeRange'[Value])))),
--Remove SWITCH below if you only want time range
SWITCH(SELECTEDVALUE(TimeRange[Value]),
"Goal", [List Price] * 1.2,
"Forecast", [List Price] * RAND()
)
)
RETURN
FORMAT(Val, "CURRENCY")
Create the Matrix
Create a Matrix visual
and drop the columns into the following rows and columns:
You will have
something that looks like this:
Are you ready for the magic? Head over to the far right of the visual and click down on the “Expand all down one level in the Hierarchy” button -> and BOOM!
We have our fully functional time range matrix that will adjust dynamically based on the current day. No need to update, change or alter anything! I hope you enjoyed this tip, I certainly was excited to put this solution together. There are so many different ways you could alter this solution, using different dates (swap in fiscal calendar dates), add different final total or percentage columns at the end, my mind keeps coming up with new solutions, and I hope you can use this as well!
You can find the full solution in this PBIX download which includes the sample data set.
If you like the content from PowerBI.Tips, please follow us on all the social outlets to stay up to date on all the latest features and free tutorials. Subscribe to our YouTube Channel, and follow us on Twitter where we will post all the announcements for new tutorials and content. Alternatively, you can catch us on LinkedIn (Seth) LinkedIn (Mike) where we will post all the announcements for new tutorials and content.
As always, you’ll find the coolest PowerBI.tips SWAG in our store. Check out all the fun PowerBI.tips clothing and products:
After many requests, we are now selling out layouts unbranded so that you can use them in all your business applications. Be sure to check out our first offerings and stay tuned for more to come in the future.Learn more about Layouts.
I’m a lazy engineer. Let me qualify my statement. In lazy I mean I like to find the path of least resistance, the shortest distance between two points. Everyday I challenge myself to be lazy, or efficient how ever you want to view it. As I have built many reports in Power BI over the years here is a fantastic trick, I use almost every day, Customizing the Quick Access Toolbar.
Here are a couple reasons why I think this will speed up
your report writing.
There are only a few shortcuts that I am aware
of for Power BI Desktop, thus making your own shortcuts with Hotkeys is faster
for repetitive tasks.
To achieve a simple task, you might have to jump
between ribbons, again adding time.
When you set up Hotkeys you don’t have to remove
your hand from the keyboard and wiggle your mouse around then come back to the
keyboard. Again, wasting time.
Enough reasons, if you are still reading this then clearly
you are lazy like me. Let’s just get to
the good stuff…
By default, you get the following Quick Access Toolbar:
The icons are Save, Undo, and Redo.
While these icons are good, YOU DON’T NEED THEM… lol
You can automatically save by using Ctrl + S
Undo is simply Ctrl + Z
And Redo… lets be honest no one uses this one.
Another aspect of the Quick Access Toolbar is when you hit
the Alt key you can reveal numbers on the toolbar:
Pressing the number or letter triggers the next button
press.
Example:
Alt + 1 will automatically save the file
To take this further you can string together multiple key
presses to dig even deeper into the menus
Example:
Alt + H + ii
brings up the import image dialog box
Alt + G + D
opens the menu to get data
Alt + W + C
Opens the Selection Pane,
Repeating this command closes the Selection Pane
The downside with multiple commands it takes more time to
learn the key strokes to be fast. As a
personal preference I like to use one-step key press options (Ctrl + s or Ctrl
+ z). It is easier for my simple mind to
remember and commit to memory. If you
use Adobe products for images or video, you will be familiar with this
technique. From my opinion Adobe has
some of the best most useful shortcuts that enhance productivity.
Make it Custom
Let’s begin customizing our menu.
First Click the Down Arrow at the far right of the
toolbar.
Click on the item
in the dropdown menu called Show below
the Ribbon. This will move the
toolbar to the bottom of the ribbon.
For each item in the dropdown list Uncheck each item, Save,
Undo, and Redo. This will remove all the items from the
toolbar.
The Quick Access Toolbar will now look like the following
image:
In our next step we need a hidden toolbar to appear, the
Format ribbon. This Ribbon only appears
when multiple elements are on the page.
Thus, we will need to add some generic shapes to the page to reveal the
toolbar.
Add three Shapes (Squares) to the report
page. Click on the Home ribbon
and select the Shapes icon listed in
the Insert section of the ribbon. Then Select the item in the drop-down list
labeled Rectangle.
After adding one rectangle select the rectangle with your cursor. Use Ctrl + C to copy the shape. Then, use Ctrl + V to past Two more rectangles on the page. Use your cursor and move the shapes across the report page. The order of the shapes does not matter, they just need to be distributed across the page. See below for reference.
Use Ctrl + A to
select everything on the page.
Notice a new ribbon appears, the Format ribbon. This is called a context aware ribbon. This has been a long standard best practice
in office products. Only show the
ribbons that are needed. Thus, the
format ribbon and the Data / Drill ribbons are not exposed until you have
visuals selected on the page.
Click on the Format ribbon. Click the
button called Align in the Arrange section of the Format ribbon. Then Right
click on the first item in the align menu called Align left. Upon doing this,
a menu will appear. Select the first item in the list called Add to Quick Access Toolbar.
Repeat the same process by adding the Distribute Vertically action from the Distribute button on the Format
ribbon.
Next, Add the Align top action from the Align button on the Format ribbon.
Finally, Add the Distribute horizontally action from the
Distribute button on the Format ribbon.
Using the combination of Aligning an Edge / Distribution is
just so much faster then moving one object at a time.
For example, here is a random arrangement of 5 shapes on a
page.
Using our newly created shortcuts I select the Items I want
to move.
Then using our new key combo, Alt + 3, Boom all the top
edges are aligned.
Then the magic, press Alt + 4 and all the items are evenly
distributed
Superfast and efficient, aka lazy..
Side Note:
When I am training new users in building Power BI reports, I like to point out the following, it is important to align your elements on the page. This follows along with one of the Gestalt principles, symmetry. Your eye can perceive slight differences in objects that are misaligned. I can’t tell you the number of reports has something like the following:
The change is subtle but your eye picks it up. When these out of alignment objects are near
another visual with a straight edge it is even more apparent.
(Steps off the Soap Box) Ok, enough diversions. Let’s finish with adding two more items that
I use every time I build a report, Selection Pane, and Bookmarks Pane. We can add these items to the menu as
well.
Navigate to the View ribbon (or hit Alt + W if you want to be fancy).
Right Click on
the item called Selection Pane. Select the item in the dropdown Add to Quick Access Toolbar.
Do the same for the Bookmarks
Pane. When you are finished your
Quick Access Toolbar should look like the following:
You may be asking yourself… So why did we move the menu to
the bottom of the ribbon? We could have
just left it on the top of the screen.
You would be right. But, I do
want to point out one odd behavior when the Quick Access Toolbar is at the top
of the ribbon.
When I have multiple visuals selected on the page the
contextual menu appears. See below image
with the Quick Access Toolbar at the top:
When this happens any items to the right might get chopped
off, and you must access them using the double sideways arrow. The Alt + # keys will still work even though
the items are hidden, but I don’t like the experience of having some of my menu
items hidden. If you had many icons distributed
across the Quick Access Toolbar, say 9 of them, you would have to remember its
position in the alt keys. This is the
reason why I prefer to show the Quick Access Toolbar below the ribbon. When the context aware menus appear the Quick
Access Toolbar is not covered.
Thanks for reading along.
Have a great day and I hope this tip / trick makes you a little bit more
productive!
If you like the content from PowerBI.Tips please follow us on all the social outlets. Stay up to date on all the latest features and free tutorials. Subscribe to our YouTube Channel. Or follow us on the social channels, Twitter and LinkedIn where we will post all the announcements for new tutorials and content.
Introducing our PowerBI.tips SWAG store. Check out all the fun PowerBI.tips clothing and products: