Document your #powerbi model with #chatGPT and a #tabulareditor script and browse it in your model

Inspired by Darrens Gosbell’s excellent blog post – Automatically generating measure descriptions for Power BI and Analysis Services with ChatGPT and Tabular Editor – Random Procrastination (gosbell.com) – and my session at SQLBits 2023 where I showed how to call the chatGPT from within Power Query and how you can use the New chat (openai.com) – to describe your M code.

I thought it would be nice if I could add this as a description to my tables in Power BI model.

How hard can that be 🙂

Well, it turns out that we are not allowed to modify the table object via the Tabular #ditor and this includes adding a description to the table

So, if I created a script that added a description – it worked fine but returning to the desktop I was asked to refresh the queries and the descriptions where removed by Power BI desktop –

Well, what is supported as write operations to a model?

Calculation groups is supported – hmmm… could I use this and then actually create a calculation group with a calculation item for each of the tables in my model – that would also mean that I could create a table in my report and expose the descriptions in a report page instead of the description should be hidden away on the tooltip of a table in the field list – This could actually be quite awesome!

C# Script here we go

I know very little about how to write C# code so Darrens example and the documentation of Tabular editor was a big help and please bear in mind that I am a C# novice when reading my code

The steps needed to this is as follows (I have used Tabular Editor 3 but it should be possible to us the free version of Tabular Editor as well

Step 1 – Open your Power BI desktop file and find the external tool ribbon and click the Tabular Editor

Step 2 – Add a Calculation Group called “Documentation”

Step 3 – Choose to create a New C# Script

Step 3 – Use the following script and run it

#r "System.Net.Http"
using System.Net.Http;
using System.Text;
using Newtonsoft.Json.Linq;

// You need to signin to https://platform.openai.com/ and create an API key for your profile then paste that key 
// into the apiKey constant below
const string apiKey = "<YOUR_API_KEY>";
const string uri = "https://api.openai.com/v1/completions";
const string question = "Please describe this power query code for me:\n\n";

using (var client = new HttpClient()) {
    client.DefaultRequestHeaders.Clear();
    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + apiKey);

    foreach (var t in Model.Tables)
    {
        
        foreach ( var p in t.Partitions)
        {
            // Only uncomment the following when running from the command line or the script will 
            // show a popup after each measure
            //
            //var body = new requestBody() { prompt = question + m.Expression   };
                string _type = Convert.ToString(p.SourceType);
                string _exp = Convert.ToString(p.Expression);
        if ( _type == "M" )
            {var body = 
                "{ \"prompt\": " + JsonConvert.SerializeObject( question + p.Expression ) + 
                ",\"model\": \"text-davinci-003\" " +
                ",\"temperature\": 1 " +
                ",\"max_tokens\": 256 " +
                ",\"stop\": \".\" }";

            var res = client.PostAsync(uri, new StringContent(body, Encoding.UTF8,"application/json"));
            //res.Result.EnsureSuccessStatusCode();
            var result = res.Result.Content.ReadAsStringAsync().Result;
            var obj = JObject.Parse(result);
            var desc = obj["choices"][0]["text"].ToString().Trim(); 
          
            //Reference to your calculation group that should hold the calculation Items
            var x =(Model.Tables["Documentation"] as CalculationGroupTable).CalculationItems[t.Name];
            
            //deletes the old version
            x.Delete();

            var calculationItem1 = (Model.Tables["Documentation"] as CalculationGroupTable).AddCalculationItem();
            
            //removes any quotes in the chatGPT description
            var s = desc.Replace("\"", "");

            calculationItem1.Expression = "\"" +  s + "\"";
            calculationItem1.Name = t.Name;
            
            //Info("Processing " + t.Name) ;
            
            }
        }

    }
}

This will create a calculation item for each of your Power Query table and add a Expression that contains the chatGPT description of your M code

Example of one of the tables

Step 4 – Save the changes back to your model and you will be prompted to refresh your calculation group

Step 5 – Add a table where you take the Calculation group name and a measure that I call Query description – the value of this measure will in the table be changed to the expression of the calculation item.

https://tenor.com/embed.js

We could use the same method to document our DAX measures and put that into a calculation group as well – thereby documenting our full model and exposing the information directly in the report and not just in the tooltips of the fields.

I will try to find time to do a blog post on this as well.

Let me know in the comments if you find this useful – would very much like to hear from you.

Using Field Parameters when connecting to a #PowerBI dataset or Azure Analysis Services

The new preview feature “Field parameters” in Power BI desktop has opened a lot of creativity in the Power BI community.

But if you use a connection to a Power BI dataset or Azure Analysis Services – the Parameters button will be greyed out

And if you don’t have the permission to change the model you won’t be able to use the feature.

So how can we use the Field parameter filter to make field selection or measure selection dynamically?

Well – we can use another preview feature to enable this

If you have turned “DirectQuery for PBI datasets and AS” on – you will get the option make changes to this model

Clicking this will change your connection to a direct query source instead of a live connection.

When we click add a local model – we can choose the tables and measures we want to include

And our storage mode will change to “DirectQuery”

But another thing changes as well – the New parameter – Fields will be enabled on the modelling tab

And then we can start building our Field paramaters

In this case for selecting what to appear on the X-axis and another one for selecting Measures / values

And then we can make our visuals dynamic by using our field parameters in the X-axis and Y-axis in the visual

When publishing the report, it will mean that the workspace will get an extra dataset

But don’t worry the linage is visible and as it is a direct query there is no need for setting up datarefresh

If you connect a new report to the dataset you will also get the field parameters in the new report as the information is stored in the direct query dataset.

Hope you find this useful and if you do – give this post a like please

#PowerBI – Make sure the data label is visible in a bar chart

Power BI has 5 different ways of positioning data labels in a bar chart – Auto, Inside end, Outside end, Inside center and inside base.

Depending on the distribution of your data this can lead to labels are being hidden, cut off or positioned a way that looks strange for the user.

In the first visual I have modified the visual in order to control the position as the base and made the numbers visible for all the categories – this can be compared to the last where the position inside base is positioned.

In this case I find this way much better but how did I do it.

Let’s go through the process

We start by creating a clustered bar chart where we add Category to the y-axis and Sales Value on the x-axis.

If we just use the standard data labels settings we won’t be able to get the result so lets add a visual calculation that matches the highest value in the visual.

So click on add data in the x-axis field and click the visual calculation icon

This will open the pane where we can add a calculation and create this calculation. This will calculate the highest Sales Value for the Category fieldn

This will give us a placeholder that we can use for the data label.

So next thing is to change the formatting of the bars.

The layout for all series should then be changed to 100 % space between series and turn on Overlap.

This will position our Max Category Value on top of all the bars we want to show.

So select the Max Category Value series under bars and set the transparency to 100 %

We are getting closer to let’s turn on data labels

Turn the labels off for Sales Value

And then modify the data labels for the Max Category Value series to use the Field Sales Value in the Value property and position the label as “Inside base”

And now the rest is formatting the number format and make sure your combination of label color and bar color is good.

In this example I have added title, subtitle, added divider to titles, removed legend and turned the values of for the x-axis.

Do you like it – then give it a like 😀

#PowerBI – Combine visual calculations and numeric parameters to create a dynamic moving average period

With the introduction of visual calculation in the February 2024 release of Power BI desktop (https://powerbi.microsoft.com/en-us/blog/visual-calculations-preview/) – this gives us some new possibilities to add calculations on the individual visual and some new functions gives us some exiciting options.

One example could be to use the MOVINGAVERAGE function (link) to and combine it with numeric range parameter to make it dynamic.

Let me take you through how this can be done

As an example file I have used the datagoblins contoso file sample file that you can download from here (link)

I have added a measure for Sales Value and some time intelligence function to filter the development chart for the selected time intelligence period.

Let’s start by adding a moving average with a visual calculation – If you have enabled the preview feature via options you should see the “New calculation” button enabled in the ribbon.

When you click this the Calculation editor will appear

If change the name and click the fx – you can select a template called Moving average

This will add the formula

And you can modify it to this

The field refers to the measure you want to calculate the average for and the windowSize refers to the number of rows to include in the calculation. In my example I have week numbers on rows and I want a moving average for the last 13 weeks.

Be aware that the documentation describes the optional arguments as well – click on the image to see the official documentation.

When committing the formula you will see the result

And going back do the report we now have a line showing the moving average for Sales Value for the last 13 weeks … 👍

But what if the user wants a little more control over the length of the period ??

My first thought was – let’s just add a slicer with a numeric range parameter – So I clicked the Numeric range under New Parameter

And created it like this

And with some formatting I ended with this slicer

And in the model we can refer to the value of the parameter via created measure “Moving Average Value”

Next step is to modify the visual calculation

Then I thought lets replace the constant value with the parameter measure value

But in the intellisense I found I couldn’t refer to all measures in the model only the add fields was visible

Okay – lets see if we can cheat – so I added the parameter value field as a tooltip

This meant that I was able to refer to it …

But only to be hit be the constraint in the function that the window size must be a constant value

hmmmm… what to do ?? – So I decided to make the solution a bit simpler…

First I changed the parameter table constructor from 1-26

to only 4 different values

And then modified the slicer to the new slicer and added some formatting and placed it on top of the development chart.

And then I modified the visual calculation to

Moving Average = 
SWITCH(
[Moving Average Value],
3, MOVINGAVERAGE([Sales Value], 3),
6, MOVINGAVERAGE([Sales Value], 6),
9, MOVINGAVERAGE([Sales Value], 9),
12, MOVINGAVERAGE([Sales Value], 12),
MOVINGAVERAGE([Sales Value], 12)
)

So when ever the user picks another value in the slicer the switch statement will evaluate the current value of the Moving Average Value – and use the appropriate constant value,

And with some further formatting and subtitle we end up with this

You can download the example file from here.

Let me know if you find this useful and/or give the post a like 🙂

#PowerBI – update your measures without the formula bar

The introduction of the DAX query view (official blogpost) and the new INFO DAX functions (official blogpost) gives us some very possibilities to update our measures without using the formula bar.

We can for instance create a query that shows all the measures that has an error message like this

EVALUATE
VAR _X =INFO.MEASURES()
RETURN
FILTER(_X, [ErrorMessage]<>"")

This will extract all my measures in the open power bi file that contains an error message.

In this case I have a measure that contains an error message telling me that I can’t use a True/False expression to filter a table. Normally you would probably search for the measure and the field list and modify via the formula bar but there is another way and will make it possible to test it before you update it.

Let me show you how 😀

The INFO.Measures() also returns the expression for the measure

Select the expression and press CTRL+C to copy the expression

Then go to the DAX query and type in DEFINE followed by a line break and then use intellisense to find the Measure and paste the copied expression – this look something like this

As soon as you start to modify the expression of the measure the text “Update model: Overwriting measure” will appear

And if you want to test it before you hit the update model “button” – you can add an EVALUATE statement and see if the measure works as intended.

When you click to update – you will get a warning that tells you that there is no way to Undo it – so be sure 🙂

Hope you this can help you and if you like it – please give the post a like 🙂

#PowerQuery – Get the population (or any other) data from Statistics Denmark into Power BI

It turns out that the blogpost I wrote 10 years ago about getting data from Statistics Denmark into Power BI with Power Query still is being used – 😊 – link.

But as the API has changed a bit since then I was asked to do an update of the blogpost – so here is how you can get the population of Denmark imported into Power BI with Power Query.

The source

Statistics Denmark provides you with a lot of information about Denmark. These data can be accessed via this site – Statistics Denmark (dst.dk). When you manually want to download the data you will find all the tables in Statistikbanken (statbank.dk)  – which provides an interface to setup a report that you then will be able to download in different formats.

In this example, I set up a simple report and you can see the export formats here.

As a Power BI developer we don’t want to do this – we want to automatically retrieve new data – API to the rescue

The Statistics Denmark does provide an API that we can use to extract the data automatically.

Its located here – Databank API – Statistics Denmark (dst.dk)

Let’s extract the Population for Denmark

When we click the button “START CONSOLE” we get this

We want to retrieve data so pick that under 1) Choose API call

Under 2) Choose settings for call we first need to select whether to do a get or a post call – we can do both but a post call requires a bit more manual code so I will stick to a get call. (If you want to know how to create a post call in Power Query – I can recommend this article from Chris Webb – Chris Webb’s BI Blog: Web Services And POST Requests In Power Query (crossjoin.co.uk) or my own here – Specifying JSON Query in Power Query – Example Statistics Sweden – Erik Svensen – Blog about Power BI, Power Apps, Power Query (wordpress.com).

Next is to specify the table name

In the Table id I have specified “Folk1a” – you can find the different table names in Statbank (id highlighted in green)

Next – select the Format “CSV” as this is the binary format the API will return to Power Query.

When you click more settings, you can change the delimiter if needed.

Next up we will click the Variable- and value codes and this will give us the opportunity to select what data we want to extract from the source.

You can click the individual items/codes or click on the * to get all elements from the variable.

In this example I have picked all KØN (gender), all ALDER (ages), total for CIVILSTAND (marital status), All – TID (time) and all OMRÅDE (regions and municipalities)

Under Other settings I leave it to default but you could change the language to English for instance

Under 3) Call the API with the chosen settings

You can see that a URL with the query is created for you.

You can then click Execute to see the result

OOPS – the API is limited to 1.000.000 cells

So, it’s telling me to extract the data either by using BULK or another streaming format instead.

Go back to 2) Choose setting for call

And select BULK under Streaming.

The URL under 3) will now be changed

And you could try and execute the query once again and the result will be shown after a while.

Copy the URL …. And then

Let’s do it in Power Query

Open Power BI Desktop and click get data and choose Web

Paste the URL into the dialog box and click OK

Very quickly you will get this based on the first 200 rows

If the Query is what you want, then click Load but you should really click Transform Data to control what data is imported to your model – so click Transform Data

And wait a couple of seconds for the preview data to load.

The data contains total lines, text after ages, not a proper date for the time and a few other transformations before we are ready to import the data in to our data model.

I won’t go through each of them but have a look at the file.

You can modify the URL to change what time is imported and make it dynamic depending on what you want imported instead of just all periods.

The API is not the fastest so the appx. 1.2 million rows this selection returns takes a couple of minutes to update.

And then we can start to create explicit DAX measures and visualize our data.

In the demo file I have created this page to create an overview of the change in the population between two different periods in top x municipalities in Denmark.

You can download the demo file here – and just click refresh to get the latest data 😊

Let me know what you think and if you like it give the post a like please.

Stay Queryious !!!

Create a dynamic slicer with field parameters with core visual – #PowerBI –

Last week I found a nice little hack that enables us to create a dynamic slicer with one or more levels and let the user pick the different levels in the slicer.

This has been very useful in one of our solutions for our clients where it can limit the number of slicers needed in a report.

First we will create a field parameter in our model where we add the different fields we want to be able to slice on

From the product table I select different fields and place them in the order I would like them sorted.

 

Just leave the “Add slicer to this page” on to add a slicer by default and the slicer looks like this.

 

Now add a table to the page and add the field parameter as the columns field.

 

As we haven’t selected any fields from the slicer, we will see all the different values in the fields.

Now change the visual to a slicer (not the new button slicer) and notice what happens.

The visual is now a slicer containing the values from the different fields.

And you can now select the fields you want to have in the slicer

 

And if you want them in another ordinal level you select the first level and then CTRL click the next the level – in this example Class and then Category

And notice the slicer header is automatically populated with the field names

You can download a sample file – here.

 

 

 

 

#PowerBI – Set a background to a URL image without a theme file

Quick Power BI tip here on a wonderful Monday morning – that I just discovered.

It’s possible to use a image URL as your background to your canvas – I used to think that this was only possible via a Power BI theme file – but no… that’s not the case.

I am using Power BI Desktop Version: 2.121.644.0 64-bit (september 2023).

Here is how…

In the format pane find the “Canvas background”

In the Image property – click the browse icon

And as the file name paste in the image URL – make sure the url returns an image

If the image is not shown

Then modify the Image fill and transparency.

Hope you find this useful.

#PowerBI – Control the sorting when using a field parameter selection as value in visual

Just a quick post on how you can control the sort order when using a field parameter as value in a visual in Power BI.

In my scenario I have created a field parameter to choose between showing Sales Value and Sales Units

And now I can use this as the y-axis in a column chart.

And let the user select whether to show Sales Value or Sales Units.

 

The column chart only has one field on the x-axis – but if I add more than one field or a hierarchy the sorting won’t work as you might wish for.

As soon as we add another level – the sorting will be default jump to sorting by the level we have drilled too in the visual

Now sorted by chain in alphabetical order

Now we can change it manually so a sort by the current selection of field parameter.

But if we change the field parameter to show Sales Units – the visual will jump back to sorting alphabetically by the selected level on the x-axis.

 

This might be the default way of doing it but if you always want the chart to be sorted by a particular measure even though you are showing another measure then you can use this workaround. You should of course inform the user about the chosen sort order for instance in the subtitle or similar.

WORKAROUND

 

Let’s say I always want to sort the chart after Sales Value – then I can add the measure as a tooltip to the visual.

 

All the different fields you add as tooltips can also be used to sort the visual by

 

And now the sorting will always happen on the selected tooltip value instead of the field on the x-axis.

Here we show the Sales Value

 

Remember – This workaround is only relevant when you have more than one field on the x-axis – but we typically do for drilling up and down so hopefully this little tip can help you two.

 

 

#PowerBI – Create a sparkline in the new card visual and some other nice formatting options

In the June 23 release of Power BI desktop we has been blessed with a new card visual that not only will give a better performance compared to adding multiple cards in the past but it also gives us some formatting options we have been dreaming of for a long time.

Here is a link to the official blogpost – New card visual | Public preview | Microsoft Power BI Blog | Microsoft Power BI

On social media you have probably already seen a lot of examples of usages, and I wanted to share how you can add a sparkline to the card to make it look something like this.

The demo dataset is based on hourly temperature data from a weather station in central Copenhagen Denmark – shared via Danish Meteorological Institute – Open Data – DMI Open Data – Confluence (govcloud.dk) and the model imports data from their API for the period of 2022-01-01 until yesterday of the writing of this blog post.

Let’s try out the new and the old card

When first added you might think … hmmm that is not really a big difference – BUT the BIG difference lies in your formatting options and that you can add more than one measure to the visual.

With the old card you would have to add a second Card to your report and sending two queries to your dataset instead of 1 as the new visual will do. Better performance – YES thank you.

In this post I will focus on how we can use the formatting options to make it really stand out.

Formatting options

Each of the measures you add to the visual can be formatted individually via the Cards properties

Let’s start by adding an accent bar to the left

Tip – Notice that the color can be controlled by fx meaning that you could make the accent color change depending whether the temperature was higher or lower compared to last year.

Another way of adding an accent bar is to use an image via the Fill properties

And then via the image control the location of your accent bar – the image is however static and can’t be controlled by a formula.

The values and label is formatted via the Callout section of the visual

Here you should especially notice that we now can control how blank values should be shown ️

Here is the default way

And here telling the user that there is no data

The label can also be controlled by an expression –

Giving us the possibility to give feed back to the reader whether the temp is higher or lower than last year for instance.

Here is the DAX measure linked to the label

Feedback on temp = IF([Avg Temperature] > [Avg Temperature LY] , "Avg temp - higher than last year", "Avg temp - lower than last year")

But now it’s time to look at how to add a sparkline

The property we have to use to do this is the Image property in the Cards section.

The Image type can be two different types – either an image or an image URL

When you pick the image URL

Notice that it can be a static URL or based on an expression

So I connect the Image URL to my Field called Temperature Sparkline

OBS – Remember to set the Category of your expression to Image URL

OBS – One thing I have noticed is that I have had to change the Size from Auto to a particular px size for it to work.

And now the card has a sparkline

In my formula I have also added the change value compared to last year average temperature.

So how did I make the formula to create the sparkline

I took a look at Kerry Kolosko amazing templates for SVG’s

Chart Templates – EXPLORATIONS IN DATA STORYTELLING WITH POWER BI (kerrykolosko.com)

And modified a bit to fit the column names in my model and then added a text element to show the change.

Here is the DAX measure

 

Temperature Sparkline =

// Line and area colours – use %23 instead of # for Firefox compatibility (Measure Derived from Eldersveld Modified by Kolosko)

// “Date” field used in this example along the X axis

VAR
XMinDate = MIN(Observations[Date])

VAR
XMaxDate = MAX(Observations[Date])

// Obtain overall min and overall max measure values when evaluated for each date

VAR
YMinValue = MINX(Values(Calendar[Date]),CALCULATE([Avg Temperature]))

VAR
YMaxValue = MAXX(Values(Calendar[Date]),CALCULATE([Avg Temperature]))

// Build table of X & Y coordinates and fit to 50 x 150 viewbox

VAR
SparklineTable = ADDCOLUMNS(

    SUMMARIZE(‘Observations’,Calendar[Date]),

        “X”,INT(150 * DIVIDE(Calendar[Date] – XMinDate, XMaxDate – XMinDate)),

        “Y”,INT(50 * DIVIDE([Avg Temperature] – YMinValue,YMaxValue – YMinValue)))

// Concatenate X & Y coordinates to build the sparkline

VAR
Lines = CONCATENATEX(SparklineTable,[X] & “,” & 100-[Y],” “, Calendar[Date])

// Add to SVG, and verify Data Category is set to Image URL for this measure

VAR
SVGImageURL =

    “data:image/svg+xml;utf8,” &

    “<svg xmlns=’http://www.w3.org/2000/svg&#8217; x=’0px’ y=’0px’ viewBox=’0 0 150 100′>” &

     “<polyline fill=’%232e4e6a’ fill-opacity=’0.3′ stroke=’%232e4e6a’

      stroke-width=’3′ points=’ 0 150 ” & Lines & ” 150 100 Z ‘/>

      <text font-family=’Segoe UI’ font-size=’24’ x=’90’ y=’20’> ” & FORMAT([Avg Temperature Chg], “#0.0” ) & “</text></svg>”

RETURN
SVGImageURL

The measures can/should be modified to fit your column names and measures and could be made even more dynamic using field parameters – but that might come in a later blogpost.

Link to the demo file

You can get a copy of the demo file here – Link

Do this as well

Give feedback to (2) PBI Core Visuals: Overview | LinkedIn on LinkedIn or directly to (2) Miguel Angel (@myersmiguel) / Twitter – who is doing an amazing job improving the core visuals in Power BI.

How to try/test another #PowerBI theme on your existing reports in the service

I am a big fan of using themes in Power BI but the current theme designer in Power BI desktop is very limited and doesn’t support all the things you really can do with themes.

So I use the excellent theme designer tool from powerbi.tips – https://themes.powerbi.tips/themes/palette

And I use the paid version so I can save my themes that I use for different clients.

The tool also has the excellent option of showing demo visuals to get a feeling of how it will look.

But I want to see how my new theme might look on some old report where I might have used another theme or perhaps some reports other users have created where they have done some individual formatting instead of using the theme.

And did you know – we can do it and see the result for existing report in your workspaces – and we can directly modify the theme and see if we should change a color or a font size or a….

Here is how

The Microsoft Power BI Embedded playground – Power BI Playground – gives us the option to try the developer sandbox

When you sign in to the playground with your credentials and click “Select Report” under use my own Power BI report

You will then be able to select an existing report in your Power BI tenant that you want to work with.

This will open the report in the playground and give us the opportunity to play around with the different report APIs that is available.

In this case I opened a report that I want to try and change the theme on.

Under the Layout group there is an item called “Set report theme”.

If you drag that into the code area

A code snippet with a custom theme will be added.

This is short theme file you see from row 95 to 101.

And when you click on Run

You will be able to see the awesome look of the new theme

This quickly reveals that the current theme file contains some drastic changes and we can start playing around with other color by changing the code.

Here the primary color is changed to a dark gray.

As you noticed the theme only has about 6 lines and very few settings so why not try the theme I have created in Theme generator from PowerBi.tips – so I download the file to my desktop and open it in

visual studio code.

And then I copy all the text from the editor and replace the existing theme

With the new theme code – be careful when you replace the text – you should have a ; (semicolon) at the end

Now let’s see how it looks.

And as you can see, I still need to do some work in the theme file to make it look pretty

This hopefully gives you an idea of how you can test your theme file directly on existing reports without having to download the pbix and import theme file and revert back and forth.

During my playing around with the theme generator and the playground I have come up with a few ideas that I will provide to the guys at PowerBI.tips and I am sure that they are interested in feedback from you as well on how they can improve their tool.

#PowerBI – Adding a vertical bar to your slicer

Yesterday I worked on a Power BI report where the client wanted to add vertical bar next to the slicer in order to make the design of the slicers a little bit nicer and also to make the slicers recognizable cross pages by using the same coloring.

My first choice was to use a shape and group it together with the slicer

But there is an easier way.

Use the Shadow properties of the slicer.

If you choose the Custom Position

You set the

Size to 0 px

Blur to 0 px

Angle to 180 (if you want the bar to the right of the slicer you can specify 0)

Distance 10 px (determines the width of the bar)

Transparency 0 px

These settings will set the slicer to look like this

And you avoid having shapes and grouping on your page

If you change the slicer to a tile or vertical list the bar will also be there

Hope you find this useful.