welcome back to Power bi helpline can you create such visuals without using any custom Visual and power bi let's do that if you want to create this visual you will think about the infographics custom visual we will not use that but if you are not aware about that let me show you how can you get that custom visual if you click on get more visuals it will take you to the custom visual store from here you can search for the visuals and import it for your use in this video we will not use any custom
visual so I am not importing this first of all open a blank PPT and click on insert then select icons you will get here many different kinds of icons which you are required to save in SVG format this solution is a little bit tricky because it will use SVG combined with Dax to get this functionality in power bi as said I will save both of these images in SVG format and keep it in a folder for now here are my icons select the first icon right click and open with notepad or vs code here is
the SVG code for this image first of all I need to replace all double quotes into single quotes so I will select all and then press Ctrl H and replace it I need parts of this code at different places for now I will copy only this much part and I will store this in a Dax measure as a string for that click on new measure and name this measure as mail icon and then copy the code here and enclose inside double quotes repeat this step for another icon and store it in another measure called female
icon alright now I will create my master measure but before that let me create a table visual which I will need at later stage with my solution I need to format this table such that the column header is not visible for this moment I have kept my total sales and cost measure here remove the grid lines and header if you are wondering why is this required then hold on you are one step closer to see the magic of Dax with SVG codes click on enter data and then create a table named as gender here I
will have only two rows male and female earlier I posted a video for this visual with similar approach you should check that out alright click on load to load the gender table in the data model now click on new measure and be ready to create the master Dax measure which will do all the magics here I will create few variables and the first one will be called as start for this open the SVG code of one of the icons and copy the first part of it till this SVG then store this in our first variable
as a string format this is a Dax measure so I will replace these double quotes with single quotes since this is an image source I also need to apply an encoding before this code you can find this code here in different formats for this demo I will use this utf-8 but if you want to use base64 format you can use this code so I have added this encoding here the second variable will be used at the end of the code basically I will use the parts of SVG and Dax in between to fill the icons
based on the measure values as said I have added this string as the second variable the next variable is to fill height and here I will calculate the percentage of the total for selected value for my gender column we have used this Dax measure many times to calculate the percentage of total I am using selected value because I will add this column in the column header of my Matrix visual all right the next measure will be used for the unfilled area of the icon so I can simply use 100 minus fill height so that it
will change the values dynamically since I also need to show the data label as text so the next variable is nothing but the same this is the format of the text element which we can use and if required we can add more formatting like font type size Etc I have already created with the required font size and color so that I will replace this code with my custom code for now I have used a single hex code but I will make it dynamic in a while filled height will be used as the text here the
next and the very important variable is called definition which will Define how the color will be filled inside my icon for that I will use clip path and assign an ID for this element filler element is rectangle where my X Position will be at zero and the Y Position will be the variable called remaining which will tell us till what position color should be filled width will be full which is 100 and the height will be till fill height variable value and last close the clip path and the container element next set of variables will
be used to decide which color to be used for filled and an unfilled area for blank area it will fill with light gray color but it will then use this Dax expression to find what is selected in the column header to choose the relevant icon for male or female codes we have already stored with these measures called mail icon and female icon I can now copy this code to use into the next variable for filled area I can change the variable name and then I need to also change the color for now I am adding
a single color but we will make this also Dynamic based on male or female selection I also need to refer the clip path because this color is used for filled area and this should trace the clip path I can copy the clip path ID and use here in my return statement I will just concatenate all these required variables in a line so that it will form the complete code with Dynamic values and selection let's now use this Dax measure in our visual select the already formatted Visual and change this to a matrix visual then remove
these measure from here and add our Master measure into that it will not show anything but once you will drag the gender column inside the column header area you will immediately see the icons if you see this it means in your data model it has already detected the relationship with customers table which you need to delete this may happen if you have Auto detect relationship settings activated in your power bi desktop as said we don't need this so delete this relationship and then check the visual this is working but I still need to format a
little bit for the correct text and the dynamic colors so I'll open my Dax measure again and we'll do the required changes first of all I can format my text to show with two decimal digits for this I can use the format Dax function and mention the required format string you can see the text is now in proper format let's Now set the dynamic colors for male and female for that I need to change this hard-coded color and I can use this already used expression where I will be required to just change the measure references
and set with different colors here it is referring to mail icon and female icon measure I will change with color codes for mail I can use the same color and for female I can use a different color in this demo I am using these colors but you can use any color code based on your requirements since the text color should also match with these colors I will copy the same code and I will replace the hard-coded color of the text element and we are now ready with our Solutions click on OK and check the visual
you will see the different colors at present there is still one problem which is if you hover over to these icons you will see the SVG codes and to remove that we need to use a report level tooltip for the same so I will quickly create a report level tooltip where I will just show the same percentages creating the tooltip page with just a card visual if you want you can create any other relevant tool tip for this purpose if you are creating any such tooltips make sure to hide the same otherwise that will be
visible as a separate page in your power bi report as said I am creating a measure with same Dax expression to calculate the total sales based on gender now you don't need any further work around and you can use this visual in your reports please check the performance before using many such SVG images in your power bi report because this may impact the performance so use it accordingly thanks for watching please subscribe to our channel for many such amazing videos in power bi post your feedbacks and suggestions in comment box [Music]