Solved

Filter by logged user

  • 31 May 2023
  • 6 replies
  • 55 views

Hi guys,

Is there a way how to filter data through logged user?

userDataFilters works pretty good, but only for static variable, for example:

{

    "data": {

        "type": "userDataFilter",

        "id": "filter1",

        "attributes": {

            "maql": "{label/email} = \"a@b.com\"",

            "title": "Filtr prodejce"

        },

        "relationships": {

            "user": {

                "data": {

                    "id": "",

                    "type": ""

                }

            }

        }

    }

}


Is it possible to change magl from static a@b.com to logged user mail?

Thanks a lot.


Ondrej

 

icon

Best answer by Joseph Heun 1 June 2023, 07:13

View original

6 replies

Userlevel 3

Hi Ondrej, 

The MAQL parameter is the expression used to create the filter, so therefore you need to have the email as an object within the LDM. Could you explain a bit about the use case here and what exactly you are trying to achieve?

Hi Joseph, I am trying to filter report acording to logged user.
For example there is four values in table:

ID NAME EMAIL
1 a a@b.com
2 b a@b.com
3 c b@b.com
4 d b@b.com

 

If I log in as “a” (with mail a@b.com), I will see only ID 1 and 2

If I log in as “b” (with mail b@b.com), I will see only ID 3 and 4

If I log in as “c” (with mail c@b.com), I will see nothing

Thanks, Ondrej

Userlevel 3

Hi Ondrej, this is how the user data filters work. Once you create a maql expression to limit the data, you then assign it to the user, using a specific userID. UserID’s are unique, and they cannot contain more than one email address/login. Therefore, you would still need to assign the data filter to each specific user id

Ok, but how to write maql expression to achieve that?

I hope I don't have to create a condition for every user (because there is a lot of changes in user structure in time):

  • for user a: "maql": "{label/email} = \"a@b.com\""…
  • for user b: "maql": "{label/email} = \"b@b.com\""...

I expect one condition for usergroup, where I put

  • "maql": "{label/email} = [logged_user_email]"… where  [logged_user_email] is email of logged user…

Is it possible to find [logged_user_email] for maql usage? is it possible to use user data to maql extension? If yes - how?

Thanks, Ondrej

I am searching for similar function like userprincipalname() in DAX…

 

Userlevel 3

I’m afraid at this moment you need to assign the expression to each user, as this feature is not available. We can certainly mark this down as product feedback for you on your behalf and have our product team review such a feature. 

Reply