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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
MWilson929
Frequent Visitor

Dynamic Column References

Hi,

 

I have a few matrix reports in my pbix file. On is on Values;

 

CY Value, LY Value, % Change

 

Another is on units;

 

CY Units, LY Units, % Change

 

I can calculate the % Change for values as;

 

% Change = (Sales[CY Value] - Sales[LY Value]) / Sales[LY Value]

 

The only way I know to create a % Change for Units is to create another % Change measure. Is there a more efficient way of doing this in DAX so there is only one percentage change measure? I'm thinking along the lines of;

 

% Change = (Sales[Column 1] - Sales[Column 2]) / Sales[Column 2]

 

Relatively new to DAX, so if anyone can advise me on best practice, that would be amazing.

 

Many Thanks,

 

Mark

1 ACCEPTED SOLUTION
prateekraina
Memorable Member
Memorable Member

You can use the "Invoke Cutsom Function" feature of Power BI Query Editor to create a function to handle this calculation.

Refer Chris Webb's blog for more details.

 

Edit 2: Ignore Column 1 and Column 2 Parameters in the image, those have nothing to do with the solution.

 

Edit 1: I have tried your scenario and was able to create a function as suggested in the blog. It would look like this:
Step 1: Create function using blank query optionStep 1: Create function using blank query optionStep 2: Select Invoke Custom function in your table and configure to get resultStep 2: Select Invoke Custom function in your table and configure to get result

View solution in original post

1 REPLY 1
prateekraina
Memorable Member
Memorable Member

You can use the "Invoke Cutsom Function" feature of Power BI Query Editor to create a function to handle this calculation.

Refer Chris Webb's blog for more details.

 

Edit 2: Ignore Column 1 and Column 2 Parameters in the image, those have nothing to do with the solution.

 

Edit 1: I have tried your scenario and was able to create a function as suggested in the blog. It would look like this:
Step 1: Create function using blank query optionStep 1: Create function using blank query optionStep 2: Select Invoke Custom function in your table and configure to get resultStep 2: Select Invoke Custom function in your table and configure to get result

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.