cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
benswift Regular Visitor
Regular Visitor

DAX 'IN' operator works in Desktop but not Service

Using Power BI Desktop and the Power BI Pro trial version I followed these steps:

 

1. Create a Role as follows in Desktop to restrict access to data for the following US states in our dataset:

   [State] IN ("DC","MD","MO","VA")

2. Used View as Role to confirm that this behaves as expected (only these four states appear).

3. Published to Service.

4. Used Test as role in Dataset Security but report is then blank, i.e., displays no data.

5. Changed syntax in Desktop to the following:

   (
   [State] = "DC"
   || [State] = "MO"
   || [State] = "MD"
   || [State] = "VA"
   )

6. Tested in Desktop and works as expected.

7. Published to Service and the filter now works (data for four states is displayed).

 

IN seems much more practical than OR and I've seen on postings that 'IN' was recently implemented in DAX for PBI, but maybe there's still a bug?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-qiuyu-msft
Moderator

Re: DAX 'IN' operator works in Desktop but not Service

Hi @benswift,

 

To use IN operator, we need to use curly braces "{ }". See: DAX Operator Reference.

 

In your scenario, please modify the role in desktop as below:

 

[State] IN {"DC","MD","MO","VA"}

 

Then republish the report to service, Test as role should work.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
PavelR Established Member
Established Member

Re: DAX 'IN' operator works in Desktop but not Service

Hi @benswift,

 

very interesting. I reproduced your steps and you are absolutely correct. IN function doesn't work at all when using Test as role in Power BI service (in desktop it works well). Whereas OR works perfect either in desktop or service.

I think you should file new Issue, because didn't find any topic that would describe this bug.

 

Regards.

Pavel

benswift Regular Visitor
Regular Visitor

Re: DAX 'IN' operator works in Desktop but not Service

Hi @PavelR, thanks for looking into that - appreciated. I will file a new issue as you suggest - once I've worked out how to!

Best,

Ben

benswift Regular Visitor
Regular Visitor

DAX 'IN' operator works in Desktop but not Service

Using Power BI Desktop and the Power BI Pro trial version I followed these steps:

1. Create a Role as follows in Desktop to restrict access to data for the following US states in our dataset:
[State] IN ("DC","MD","MO","VA")
2. Used View as Role to confirm that this behaves as expected (only these four states appear).
3. Published to Service.
4. Used Test as role in Dataset Security but report is then blank, i.e., displays no data.
5. Changed syntax in Desktop to the following:
(
[State] = "DC"
|| [State] = "MO"
|| [State] = "MD"
|| [State] = "VA"
)
6. Tested in Desktop and works as expected.
7. Published to Service and the filter now works (data for four states is displayed).

IN seems much more practical than OR and I've seen on postings that 'IN' was recently implemented in DAX for PBI, but maybe there's still a bug?

@PavelR has been able to reproduce this bug.

Thank you!

Moderator v-qiuyu-msft
Moderator

Re: DAX 'IN' operator works in Desktop but not Service

Hi @benswift,

 

To use IN operator, we need to use curly braces "{ }". See: DAX Operator Reference.

 

In your scenario, please modify the role in desktop as below:

 

[State] IN {"DC","MD","MO","VA"}

 

Then republish the report to service, Test as role should work.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

benswift Regular Visitor
Regular Visitor

Re: DAX 'IN' operator works in Desktop but not Service

Thanks very much @v-qiuyu-msft, this works! However, I would still consider it a bug from the Power BI perspective - the IN statement in () should not work in Desktop if it's not going to work in the Service.

Regards,

Ben

benswift Regular Visitor
Regular Visitor

Re: DAX 'IN' operator works in Desktop but not Service

I see it's all clearly stated here: https://msdn.microsoft.com/en-us/library/ee634237.aspx

PavelR Established Member
Established Member

Re: DAX 'IN' operator works in Desktop but not Service

I agree with @benswift about that consistency between desktop and service. It is quite confusing.

 

Regards.

Pavel

Highlighted
AnandRanga Member
Member

Re: DAX 'IN' operator works in Desktop but not Service

@PavelR

@benswift

@v-qiuyu-msft

Can someone tell me how to write NOT IN, it's not working for me. My expression is:

defaulter = IF(TIMESHEETANALYSISCUBE[WORKER NAME] IN {TIMESHEETANALYSISCUBE[WorkerNameDEF]},TIMESHEETANALYSISCUBE[WORKER NAME])

But I want to use NOT IN.

Thanks for your time.

arthastic Frequent Visitor
Frequent Visitor

Re: DAX 'IN' operator works in Desktop but not Service

@AnandRanga

Marco Russo suggests next:

CALCULATE (
    [Sales Amount],
    NOT ( Products[Color] IN VALUES ( Products[Color] ) )
)

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 337 members 3,382 guests
Please welcome our newest community members: