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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
TechMG
Frequent Visitor

Convert SQL to DAX

Hi, I have a paginated report which access the source as Power BI data model, both are deployed in service. I have set of parameters exist in Paginated Report. For ex. ProgramName. It contains list of programnames and use will select the respective program for seeing the data. Now, we have RLS implemented in data model and it is working fine. However, the user can see all the programs in parameter rather he want see only his program. I am planning to restrict the program names in parameter based on user logged in to the system. I have tried below but no luck.

SQL:

select distinct P.ProgramId ,P.ProgramName ,DU.InternalEmailAddress from gold.programid P INNER Join gold.dimclinic C ON P.ProgramId = C.ProgramId INNER Join gold.userclinicbridge UC ON C.ClinicId = UC.ClinicId INNER JOIN gold.dimuser DU ON DU.UserId = UC.UserId WHERE DU.InternalEmailAddress = @UserId

DAX:

EVALUATE ADDCOLUMNS( 'Program'[ProgramId], 'Program'[ProgramName], LOOKUPVALUE('dimclinic'[ProgramId],'Program'[ProgramId]), LOOKUPVALUE('userclinicbridge'[ClinicId],'dimclinic'[ClinicId]), "InternalEmailAddress",LOOKUPVALUE('dimuser'[InternalEmailAddress],'dimuser'[UserId],'userclinicbridge'[ClinicId]) )
I need to apply filter as I mentioned in SQL. As I am new to DAX, seeking some help. Thanks

4 REPLIES 4
Anonymous
Not applicable

Hi @TechMG ,

 

Please try:

EVALUATE
ADDCOLUMNS(
    FILTER(
        'Program',
        LOOKUPVALUE(
            'dimuser'[InternalEmailAddress],
            'dimuser'[UserId],
            'userclinicbridge'[UserId]
        ) = userprincipalname()
    ),
    'Program'[ProgramId],
    'Program'[ProgramName],
    LOOKUPVALUE('dimclinic'[ProgramId],'Program'[ProgramId]),
    LOOKUPVALUE('userclinicbridge'[ClinicId],'dimclinic'[ClinicId]),
    "InternalEmailAddress",
    LOOKUPVALUE(
        'dimuser'[InternalEmailAddress],
        'dimuser'[UserId],
        'userclinicbridge'[ClinicId]
    )
)

Best Regards,

Neeko Tang

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

Hi @Anonymous 

 

Thanks for your quick response. I have executed the query and getting below error.

Query (13, 5) Too few arguments were passed to the LOOKUPVALUE function. The minimum argument count for the function is 3.

 

Anonymous
Not applicable

Hi @TechMG ,

 

I'm sorry I changed my dax.

Table = FILTER(ADDCOLUMNS(SELECTCOLUMNS('P',"ProgramId",[ProgramId],"ProgramName",[ProgramName]),"InternalEmailAddress",LOOKUPVALUE(
        'dimuser'[InternalEmailAddress],
        'dimuser'[UserId],
        'userclinicbridge'[ClinicId]
    )),[InternalEmailAddress]=userprincipalname())

Best Regards,

Neeko Tang

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

Hi @Anonymous ,

 

Tried the above solution and it is saying Incorrect syntex Table. 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.