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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Moving DAX Calculation into PQ for Query Folding

Hello,

 

I'm pretty new to Power Query, I have a table I'm pulling into PBI that was query folding back into SQL Server. I've needed to create a measure as a calculated column in PBI for some visualisations I'm being asked to create but this has broken query folding and has significantly increase refresh time. I need to create the below DAX as a Custom Column in PQ. 

 

Any help would be appreicated, below is the DAX I need to recreate. 

 

Thanks

 

 

 

 

 

Calculated Column = 

VAR _Column = DIVIDE(([VOLUME]-[COST]-[WASTE]),[VOLUME],0)

RETURN

SWITCH(
    TRUE(),
    _Column < 0, "< 0 %",
    _Column >= 0 && _Column < 0.10, "0-10 %",
    _Column >= 0.10 && _Column < 0.20, "10-20 %",
    _Column >= 0.20 && _Column < 0.30, "20-30 %",
    _Column >= 0.30 && _Column < 0.40, "30-40 %",
    _Column >= 0.40, "40 %+"
)

 

 

 

 

 

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

You can either create a new column in PQ for the variable, or you can include the variable calculation in each line of the new PQ column.

 

The first option would look like this:

// varColumn
([VOLUME] - [COST] - [WASTE]) / [VOLUME]

// newColumn
if [varColumn] < 0 then "< 0%"
else if [varColumn] < 0.1 then "0-10%"
...
...
else //your escape value

 

The second option would look like this:

// newColumn
if ([VOLUME] - [COST] - [WASTE]) / [VOLUME] < 0 then "< 0%"
else if ([VOLUME] - [COST] - [WASTE]) / [VOLUME] < 0.1 then "0-10%"
...
...
else //your escape value

 

Both options should generate a foldable CASE statement.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

You can either create a new column in PQ for the variable, or you can include the variable calculation in each line of the new PQ column.

 

The first option would look like this:

// varColumn
([VOLUME] - [COST] - [WASTE]) / [VOLUME]

// newColumn
if [varColumn] < 0 then "< 0%"
else if [varColumn] < 0.1 then "0-10%"
...
...
else //your escape value

 

The second option would look like this:

// newColumn
if ([VOLUME] - [COST] - [WASTE]) / [VOLUME] < 0 then "< 0%"
else if ([VOLUME] - [COST] - [WASTE]) / [VOLUME] < 0.1 then "0-10%"
...
...
else //your escape value

 

Both options should generate a foldable CASE statement.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.