Showing results for 
Search instead for 
Did you mean: 
New Member

convert Crystal Formula to DAX or Power Query

Hi team, 

coming from lots of years in crystal reports to now moving to Power BI and DAX or Powerquery.

This formula works great in Crystal, how can i now convert it to work in Power BI? 


IF (Mid ({CASE_CHARGE.OFFENSE_CODE}, 8,1 ) = 'F' or  {CASE_CHARGE.GRADE} in ['A', ‘B’, ‘C’, ‘F’, ‘T’] then “Felony” else

if (Mid ({CASE_CHARGE.OFFENSE_CODE}, 8,1 ) = 'M' or {CASE_CHARGE.GRADE} = 'M')  then "Misdemeanor" else

if (Mid ({CASE_CHARGE.OFFENSE_CODE}, 8,1 ) = 'O' or {CASE_CHARGE.GRADE} = 'O') then "Ordinance" else





Community Support
Community Support

Hi @shenderson2 ,


There does not seem to be an error in the logic of the formula, according to the error hint indicates that it is the field referenced in the formula that is in error.


Would you be able to provide information on screenshots of the data model, etc.? I will answer you as soon as possible.

Best Regards,


Super User
Super User

Hi @shenderson2 ,


I am not a crack when it comes to crystal report syntax, but I would translate it to this (in DAX, calculated column)

Calculated Column =
    MID ( 'CASE_CHARGE'[OFFENSE_CODE], 8, 1) = "F" || 'CASE_CHARGE'[GRADE] in {"A", "B", "C", "F", "T"}, "Felony",
    MID ( 'CASE_CHARGE'[OFFENSE_CODE], 8, 1) = "M" || 'CASE_CHARGE'[GRADE] = "M", "Misdemeanor",
    MID ( 'CASE_CHARGE'[OFFENSE_CODE], 8, 1) = "O" || 'CASE_CHARGE'[GRADE] = "O", "Ordinance",


Let me know, if this works! 🙂



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

dax error.JPGHI Tom, 


i am very sorry to tell but unfortunately it did not work. 

Have a lovely weekend


Hi @shenderson2 ,


It does not look too bad, I would say 🙂


Unfortunately, I cannot see the error message, but could it be that you tried to create a measure instead of a calculated column? 


Otherwise, feel free to share some data and I am sure we will be getting there!



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Yes, i did try to create a  measure.  It is a direct query without any data transformations so far. I tried to create a new column in the query editor using your code without success.

Helpful resources

Winner of T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Find out who won the T-Shirt Design Challenge and the top 3 finalists.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.