Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
pankajj
Helper III
Helper III

Crystal Report to Power BI query

Dear community,

 

I have an existing report done with Crystal Report.

 

While converting it to Power BI, I am stuck at the following Formula:

 

local stringvar warehouse := "";

if {Command.ABD_ORDER_POINT} - {Command.ABD_QIS} + {Command.ABD_QID} > {Command.ABDNetQty} then
(IF warehouse = "" then warehouse := warehouse + "*ABD*" else warehouse := warehouse + ", *ABD*")
else if {Command.ABD_ORDER_POINT} > 0 then
(if warehouse = "" then warehouse := warehouse + "ABD" else warehouse := warehouse + ", ABD");

if {Command.ALS_ORDER_POINT} - {Command.ALS_QIS} + {Command.ALS_QID} > {Command.ALSNetQty} then
(IF warehouse = "" then warehouse := warehouse + "*ALS*" else warehouse := warehouse + ", *ALS*")
else if {Command.ALS_ORDER_POINT} > 0 then
(IF warehouse = "" then warehouse := warehouse + "ALS" else warehouse := warehouse + ", ALS");

if {Command.ALSVC_ORDER_POINT} - {Command.ALSVC_QIS} + {Command.ALSVC_QID} > {Command.ALSVCNetQty} then
(IF warehouse = "" then warehouse := warehouse + "*ALS-VC*" else warehouse := warehouse + ", *ALS-VC*")
else if {Command.ALSVC_ORDER_POINT} > 0 then
(IF warehouse = "" then warehouse := warehouse + "ALS-VC" else warehouse := warehouse + ", ALS-VC");

if isnull({Command.NEXT_ORDER_REQUIRED_BY}) = false then
(IF warehouse = "" then warehouse := warehouse + "*" + (IF {Command.DEMAND_WHSE} = "UNIVERSAL" THEN "C2" ELSE {Command.DEMAND_WHSE}) + "*" else warehouse := warehouse + ", *" + (IF {Command.DEMAND_WHSE} = "UNIVERSAL" THEN "C2" ELSE {Command.DEMAND_WHSE}) + "*");

warehouse

 

I was able to convert the query to run in Power BI as below however Power BI is not able to recognize 'warehouse'

 

if ([ABD_ORDER_POINT] - [ABD_QIS] + [ABD_QID]) > [ABDNetQty] then
if warehouse = "" then warehouse & "*ABD*" else warehouse & " *ABD*"
else if [ABD_ORDER_POINT] > 0 then
if warehouse = "" then warehouse & "ABD" else warehouse & ", ABD" else

if ([ALS_ORDER_POINT] - [ALS_QIS] + [ALS_QID]) > [ALSNetQty] then
if warehouse = "" then warehouse & "*ALS*" else warehouse & ", *ALS*"
else if [ALS_ORDER_POINT] > 0 then
if warehouse = "" then warehouse & "ALS" else warehouse & ", ALS" else

if ([ALSVC_ORDER_POINT] - [ALSVC_QIS] + [ALSVC_QID]) > [ALSVCNetQty] then
if warehouse = "" then warehouse & "*ALS-VC*" else warehouse & ", *ALS-VC*"
else if [ALSVC_ORDER_POINT] > 0 then
if warehouse = "" then warehouse & "ALS-VC" else warehouse & ", ALS-VC" else

if [NEXT_ORDER_REQUIRED_BY] <> null then
if warehouse = "" then warehouse & "*" & (if [DEMAND_WHSE] = "UNIVERSAL" then "C2" else [DEMAND_WHSE]) & "*" else warehouse & ", *" & (if [DEMAND_WHSE] = "UNIVERSAL" then "C2" else [DEMAND_WHSE]) & "*"
else
warehouse


Looking forward for a quick help from experts in our PBI Community.

 

Thank you very much in advance.

 

Pankajj

3 REPLIES 3
edhans
Super User
Super User

"warehouse" is a variable Crystal is building. Power Query doesn't work that way. I think you'll need to rebuild it from the ground up to get the same result. It would be like copying and pasting in a formula from Excel or a SQL statement. You need to adjust it to the language you are using, which is M in this case.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

edhans,

 

Thank you very much Edhans!

 

Really appreciate your observation and recommendations.

 

Can you please suggest how to alter the formula.

 

Best regards,

 

Pankajj

I'd start one piece at a time. Create a new formula in Crystal, and do one small part. Then replicate that in Power Query. Then keep going until you get it to return the same answer. I've had to redo some Crystal Reports in Power Query/Power BI, and it is a tedious conversion. There is no automated way to do it that I am aware of.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors