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.
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?
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
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.
Quick google tells me "&" is a bitwise and operation in sql (https://dba.stackexchange.com/questions/147053/how-does-the-operator-work-in-sql-server)
October release has bitwise functions in DAX https://powerbi.microsoft.com/en-us/blog/power-bi-october-2021-feature-summary/
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?
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.
Best Regards
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |