Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
joannasokolowsk
Helper II
Helper II

Slicer always set to the top country (RLS also included)

Dear Colleagues,

I need your advice regarding slicer setp up for project where I also use row level security.

The case is as following - I created a dashboard where Leaders can see data for their countries, however there are few leaders who have 2 countries. I do not want to summarazie data for both countries so I added slicer and I would like this slicer to always select one country (could be according to alphabetical order), so those leaders who have only one country have their country selected, and the ones with more countries can change the selection (for them also one country already selected by default) . 

 

Thank you in advance!

Asia

9 REPLIES 9
joannasokolowsk
Helper II
Helper II

Hey,

It is almost about all visuals and in some cases there is a place only for one valuse (visual card).

 

I also have another issue bc it looks like I can't show both territories now - there is an error telling that desired outcome should includes only one value but includes 2 (2 countries on the list)

v-yanjiang-msft
Community Support
Community Support

Hi @joannasokolowsk ,

In your sample, as all tables are related with the Summary by country table, you can only set RLS with the Summary by country table like below:

vkalyjmsft_5-1639642137332.png

Then the country slicer should also from the Summary by country table.

vkalyjmsft_6-1639642262056.png

By test the slicer cannot be set to the specified value, you can sort it by ascending.

vkalyjmsft_7-1639642582308.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hey,

Thank you for the response! I already set up the RLS and it works! The only problem I have is the default selection on the slicer. I have some more statistics for each country so they should be displayed separately (and if there is no slicer selected then values are sum up together for both countries, which I do not want to do). 

Hi @joannasokolowsk ,

Can you provide more information about which value will be sum up together for both countries? Is it a measure or column, you can put the value and country in the same visual, they should be displayed separately.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

joannasokolowsk
Helper II
Helper II

 again thanks for the quick reply! Could you please share the solution/details for the solution you mentioned? 

Anonymous
Not applicable

I have given the detailed solution in my reply. There is nothing more to it. All the DAX codes and visual settings are mentioned in that post. Please refer to it.

joannasokolowsk
Helper II
Helper II

Hey! Thank you for detailed explanation! Let me share with you maybe more details with the project I have. 

 

I have relationships so Leaders data is in separated table:

joannasokolowsk_0-1639584004444.png

 

I have 4 data sources as below:

-> Leaders ID's for RLS

joannasokolowsk_1-1639584086909.png

-> Summary by country

joannasokolowsk_2-1639584117114.png

-> Session attendance

joannasokolowsk_3-1639584150096.png

-> Trainign status

joannasokolowsk_4-1639584189926.png

 

All relationships are made based on Country so once Team Leader open dashboard on the power bi reporting server will see only data for  connected countries. 

Now, I want to create such dashboard where Team Leader with one country see it like this :

E.g. for Anna who is a Team Leader only for Hungary with slicer (Country unique) alrady marked for Hungary

joannasokolowsk_5-1639584363996.png

While Leader who is connected with 2 countries (e.g. Tom who has Poland, Russia) will see Poland as selected by default but could also filter Russia

joannasokolowsk_6-1639584443174.png

 

I hope it makes more sence now 🙂 

 

Asia

 

 

 

 

Anonymous
Not applicable

I think it is not possible to actually 'SELECT' something based on the user in a slicer. But, we can determine a default country for every user in a calculated column using some DAX expression and that column could be used to simulate this selection. Then using a toggle or slicer, we can give the option to the users to change the country.

Anonymous
Not applicable

I will show you one workaround to do this. I am using alphabetical order to pick the first country as the default one. But you could use any dax condition, may be like the highest sales value or something to set as the default country for every user.

 

Assume you have the following table.

Table Name: 'Users Country'

sreenathv_0-1639480672494.png

Add four calculated columns to this table using the following DAX codes.

 

 

 

AlphaCode = UNICODE('Users Country'[Country])
Default Country Code =
VAR X = 'Users Country'[User]
VAR Result =
    MINX (
        FILTER ( 'Users Country', 'Users Country'[User] = X ),
        'Users Country'[AlphaCode]
    )
RETURN
    Result
Slicer Country Name =
IF (
    'Users Country'[AlphaCode] = 'Users Country'[Default Country Code],
    'Users Country'[Country] & "(Default)",
    'Users Country'[Country]
)
Slicer Country Default =
IF (
    'Users Country'[AlphaCode] = 'Users Country'[Default Country Code],
    "Default",
    "Others"
)

 

 

Please note that the first column gets a numeric code and the second column takes the minimum of the numeric code to set a default country alphabetically. I agree that there is a caveat that if two countries have the same first letter for the same user, it won't give the result. But the point is, instead of using this alphabetical thing, you could use any DAX like Max sales or something like that to pick one default country. If you have a numerical country code, you could use that. Treat this as a toy example and not as a production-grade code.

The other two calculated columns are just some texts generated based on the default country.

Once you create all these four calculated columns, your table will look like this.

sreenathv_1-1639481131069.png

Based on this, you will be able to achieve the following through various visuals. I used a toggle button, just to try it, but you could use a slicer for that also.

I have created a measure just for illustration. In reality, you won't need this.

 

 

SelectedCountry = SELECTEDVALUE('Users Country'[Country])

 

 

sreenathv_2-1639481232293.png

sreenathv_3-1639481257237.png

sreenathv_4-1639481350721.png

sreenathv_5-1639481372335.png

sreenathv_6-1639481402002.png

The "User 5" has two countries. The "select Default Country" toggle is on. So the "Selected Country" measure is showing his default country. If you turn the toggle off, the user will be able to select any other country.

sreenathv_7-1639481479434.png

I don't know how many users have this kind of requirement. But you could try out something like this as we don't have a standard way to achieve this.

 

Given below is the setting that I have used for the toggle button.

sreenathv_8-1639481666947.png

sreenathv_9-1639481701770.png

You could use a slicer instead, the toggle button is a kind of UI/UX factor. Nothing to do with the functionality.

 

 

 

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.