简体   繁体   中英

Power BI Code for filtering. Debugging Codes in M language ( Creating a column in Power BI)

I am having error Please can you help out, as I am new here

= Table.AddColumn(#"Changed Type", "Custom", each if ([Application Name] = "BBK" and (Text.Contains([Entitlement Key], "_ADMIN_BBK") or Text.Contains([Entitlement Key], "_UPDATE_BBK") or Text.Contains([Entitlement Key], "_READ_BBK")) then "YES" else if [Application Name] = "CBJ" and (Text.Contains([Entitlement Key], "_ADMIN_CBJ") or Text.Contains([Entitlement Key],"_UPDATE_CBJ") or Text.Contains([Entitlement Key],"_EXECUTE_CBJ") or Text.Contains([Entitlement Key],"_READ_CBJ")) then "YES"else if [Application Name] = "NEX" and Text.Contains([Entitlement Key], "_READ_NEX") then "YES" else if [Application Name] = "SNR" and Text.Contains([Entitlement Key], "_READ_SNR" ) then "YES" else "NO"))))

Its hard to tell what you are doing, but try

= Table.AddColumn(#"Changed Type", "Custom", each 

if (
[Application Name] = "BBK" and (Text.Contains([Entitlement Key], "_ADMIN_BBK") or Text.Contains([Entitlement Key], "_UPDATE_BBK") or Text.Contains([Entitlement Key], "_READ_BBK"))) then "YES"
else if ([Application Name] = "CBJ" and (Text.Contains([Entitlement Key], "_ADMIN_CBJ") or Text.Contains([Entitlement Key],"_UPDATE_CBJ") or Text.Contains([Entitlement Key],"_EXECUTE_CBJ") or Text.Contains([Entitlement Key],"_READ_CBJ"))) then "YES"
else if [Application Name] = "NEX" and Text.Contains([Entitlement Key], "_READ_NEX") then "YES"
else if [Application Name] = "SNR" and Text.Contains([Entitlement Key], "_READ_SNR" ) then "YES"
else "NO"
)

I did what you should have done -- tried this piece by piece, making sure that each row evaluated before adding the next. You had too few parenthesis on some places and too many in others

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM