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
piotr_gor
Helper II
Helper II

How to filter through "(DP.flag & 8192)= 0"

Hi there, 

I've got a problem. I need to recreate sql code like below in Power BI. 

 

WHERE 
  DP.subtype = 0 
  AND DK.type = 0 
  AND DK.bufor <> 1 
  AND DK.cancelled = 0 
  and kh.kod In ('INTERNET') 
  AND (DP.flag & 8192)= 0 
  AND (DP.type & 1)= 0 

Is there any way to filter "(DP.flag & 8192)= 0"? How do I do that? Do you even know what does it mean? 

7 REPLIES 7
v-yiruan-msft
Community Support
Community Support

Hi @piotr_gor ,

Has your problem been solved?  If yes, could you please mark the helpful post as Answered? It will help the others in the community who have similar problems to yours to find a solution as soon as possible. Thank you.

Best Regards

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

While choosing database I used SQL code to get data with those bits included. It was the simpliest solution while I coudn't write working DAX formula. 

Gabriel_Walkman
Continued Contributor
Continued Contributor

I coudn't google it 😮

 

Still don't know how to apply it in BI though. None of these DAX functions help me though.

I googled "dax bitwise" and I'd guess that an sql operation

(DP.type & 1)= 0

Would be in dax:

BITAND([DP.type], 1) = 0

 

No experience on those so just a guess. 

I don't have much of experience of programming (used only Python) but DAX to me doesn't make sense. 

 

I want it go every row and meet createria " ('DP'[flag]), 8192 = 0". If so return yes or 1 or whatever. How do I do that? I know it's a simple thing but cannot do it.  I need to read a introduction book about DAX. 

Hi @piotr_gor ,

"&" is a logical operator in SQL that performs a bitwise logical AND operation between two integer values. Are you trying to use DAX to implement the following SQL statement with similar functionality? Could you please provide the complete SQL statement and some sample data from the tables DP, DK and kh?

yingyinr_0-1637648147880.png

I think  @Gabriel_Walkman has given the answer on how to convert the filter condition (DP.flag & 8192) = 0 to DAX: 

BITAND(DP.flag , 8192)=0...

Also, the following links provide some good resources and tools for learning DAX, you can use them to learn DAX.

Good Source to Learn DAX

DAX Guide

DAX Formatter

Best Regards

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

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.