The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hey,
In a powerbi-file i have some related tables. Some of the relations uses a key which contains specific personal-related-information, which may not be visable to 'the whole world' (privacy rules.)
I want to hash this key and use this hashed values in the relations.
Some questions:
* is the hashing of the key possible?
* Can some give me an example how to calculate this hashing. I like to use dax-formulas, not the r-scripting.
Kind regards
Eddy
Solved! Go to Solution.
Hi @eddydm,
I haven't find any function to directly convert the string to hash string (dax and power query not contain).
For your requirement, you can try to use below methods if it works on your side:
1. T-sql.
Use a static string to instead of the privacy information or use hasbytes to transform.
2. R script.
Write a r script which use to convert the string, then run it in query editor.
3. Web.Content.
Add a custom step which use to call a transform string api/webservice.
Reference links:
Power Query Functions–Some Scenarios
Regards,
Xiaoxin Sheng
Old thread, but I had a similar need and I've found a pure Power Query/M solution to this...
M can compress binary data as gzip, the gzip footer contains a 32-bit CRC checksum which we can access and use as a uniformly sized hash:
CalculateHash = (x as text) as number => BinaryFormat.UnsignedInteger32( Binary.FromList( List.FirstN( List.LastN( Binary.ToList( Binary.Compress(Text.ToBinary(x, BinaryEncoding.Base64), Compression.GZip) ), 8), 4) ) )
The footer is 8 bytes, the first 4 of which contains the checksum. We convert the gzip binary to a list in order to extract the relevant bytes and in turn convert this to a non-negative number. Alternatively, you could use the hex value for a text hash:
CalculateHash = (x as text) as text => Binary.ToText( Binary.FromList( List.FirstN( List.LastN( Binary.ToList( Binary.Compress(Text.ToBinary(x, BinaryEncoding.Base64), Compression.GZip) ), 8), 4) ), BinaryEncoding.Hex)
This is a brilliant answer
I need user Hash md5. Can I do it on Power Bi witch M language.
The post by akristiansson is highly useful but it might be easier for typical users if Perfect Hash Functions were implemented in Power BI [1] out-of-the-box so the users would not have to resort to Power Query M:
https://crypto.stackexchange.com/questions/8765/is-there-a-hash-function-which-has-no-collisions/212...
From a personal standpoint, I should be able to figure out how to apply akristiansson's method; unfortunately, I'm not sure if the "average" Power BI users are going to want to do that everytime they import sensitive Row Ids. When users import data into Power BI, they should be given an option to supply a key that will automatically Perfectly Hash the senstive colums (without collisions) before they are loaded into Power BI. The users would then be responsible for safeguarding that key in case they ever need to apply the Perfect Hash for future imports of related data.
[1] - Also, assuming the datasource is an onsite MS SQL Server, it's posible that MS SQL Server could be modified to apply the Perfect Hash to the senstive colums before they are loaded into Power BI and/or read by DirectQuery.
Hi @eddydm,
I haven't find any function to directly convert the string to hash string (dax and power query not contain).
For your requirement, you can try to use below methods if it works on your side:
1. T-sql.
Use a static string to instead of the privacy information or use hasbytes to transform.
2. R script.
Write a r script which use to convert the string, then run it in query editor.
3. Web.Content.
Add a custom step which use to call a transform string api/webservice.
Reference links:
Power Query Functions–Some Scenarios
Regards,
Xiaoxin Sheng
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
78 | |
72 | |
46 | |
39 |
User | Count |
---|---|
135 | |
108 | |
69 | |
64 | |
56 |