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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
dhruvip23
Regular Visitor

Filtering Data using MID and SWITCH functions to apply RLS in PowerBI using DAX editor

Hey folks,

 

I have school data to filter using ENumbers where numbers are staring with 'E' followed by any 3 digits(eg. E1234, E2134, E3124, E4321). If the first number followed by 'E' is starting with 1 it should return data for School 'A', with 2, data for School'B', and so on.  I want to apply RLS so that only 'school A' can see the data related to that school and so is the others.  

 

I have an exaple which I've applied in SSMS using DAX, working fine while retrieving the data but giving me an error while applying it with DAX editor to apply RLS.

 

EVALUATE 
  SELECTCOLUMNS(SchoolInfo 
  , "SchoolENumber", SchoolInfo[CEM ENumber]
  , "SchoolCode" , MID(SchoolInfo[CEM ENumber],2,1)
  , "SchoolLabel" , SWITCH( MID(SchoolInfo[CEM ENumber],2,1)
            , "1" , "A"
            , "2" , "B"
            , "3" , "C"
            , "4" , "D"
            , "Unknown")
  )

 If anyone can help me with this that would be great. Thanks in advance.

1 REPLY 1
FreemanZ
Community Champion
Community Champion

Hi @dhruvip23 ,

 

not sure if i really get your point, but you might need to add the SchoolLabel column as calculated column and use that column for RLS. 

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.