Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello all! I'm fairly new to using DAX and Power BI and I keep getting stumped using the IF function.
I'm trying to create a new column in 'edit queries' where I'm trying to classify account codes by account type. Specifically, I have a column of Account Codes (7010, 7209, 7997, 8010, 8116, ect) and I want all the accounts beginning with 7 to be classified as "Personnel," and all the accounts beginning with 8 to be classified as "General". (All the account codes begin with 7 or 😎
I assumed that I would be using an IF function, however, I'm not sure what the correct formatting is and I keep getting error messages particularly this one: DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
I've tried many different functions. This is the latest one I've tried:
Column = IF(DimAccount[AccountCode]<=7999,"Personnel","General")
Any feedback would be much appreciated!
Solved! Go to Solution.
Hi @techtina make sure thar Account Codes columns is not a text field.
@Vvelarde is almost certainly right; the workaround is just to change your formula to:
Column = IF(VALUE(DimAccount[AccountCode])<=7999,"Personnel","General")
However, I would say better practice might be:
Column = IF(LEFT(DimAccount[AccountCode]) = "7", "Personnel", "General")
just because it makes it a bit more clear to me. Your call.
Hi @techtina make sure thar Account Codes columns is not a text field.
@Vvelarde is almost certainly right; the workaround is just to change your formula to:
Column = IF(VALUE(DimAccount[AccountCode])<=7999,"Personnel","General")
However, I would say better practice might be:
Column = IF(LEFT(DimAccount[AccountCode]) = "7", "Personnel", "General")
just because it makes it a bit more clear to me. Your call.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
124 | |
79 | |
49 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |