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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Take the diferrence between two parameter

Hi everyone,

I created two parameters with lists of measures, two slicers and one matrix with these parameters.

My question is, Is it possible to create a measure to calculate the difference between two measures selected in slicer parameters?

I created this measures and don't bring me error messages

Diff_P1_P2 =
var Paramter1 = CALCULATE(SELECTEDVALUE(_Parameter_P1[_Parameter_Measures]))
var Paramter2 = CALCULATE(SELECTEDVALUE(_Parameter_P2[_Parameter_Measures2]))
RETURN
Paramter1-Paramter2
 
But, when I drag into pivot, show me this: 
"Columns [_Parameter_P1[_Parameter_MeasuresPivot] is part of composite key, but not all columns of the composite key are included in the expression or its depende expression"
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi  @Anonymous ,

 

I created some data:

If you want to add a row to a matrix Row, you need to create a new table column as a Row, and then create a measure that uses the switch() function to determine the value corresponding to each value.

vyangliumsft_0-1709529861620.png

 

Here are the steps you can follow:

1. Enter data – create a table.

vyangliumsft_1-1709529861620.png

According to the Power BI design, the default sorting is alphabetical, so we need an Index to customize the sorting.

[Group] – Column tools – Sort by column – [lndex]

vyangliumsft_2-1709529884028.png

2. Create measure.

Test =
SWITCH(
    TRUE(),
     MAX('Row_Group'[Group])="MEASURE1",[Parameter_Measures],
     MAX('Row_Group'[Group])="MEASURE2",[Parameter_Measures2],
    MAX('Row_Group'[Group])="DIFFERENCE",[Parameter_Measures] - [Parameter_Measures2])

3. Result:

 

vyangliumsft_3-1709529884034.png

If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

Anonymous
Not applicable

Hi my friend,

I really liked your idea, but I got a simpler solution.

The measurements are then based on a single table that isn't that big, so I made a copy of the table and created similar versions of the measurements,
like this

table 1 and measurements: 1, 2, 3
table 1a and measurements: 1a, 2a, 3a

So I created the parameters for measurements.

 

but thanks for all

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @Anonymous ,

 

I created some data:

If you want to add a row to a matrix Row, you need to create a new table column as a Row, and then create a measure that uses the switch() function to determine the value corresponding to each value.

vyangliumsft_0-1709529861620.png

 

Here are the steps you can follow:

1. Enter data – create a table.

vyangliumsft_1-1709529861620.png

According to the Power BI design, the default sorting is alphabetical, so we need an Index to customize the sorting.

[Group] – Column tools – Sort by column – [lndex]

vyangliumsft_2-1709529884028.png

2. Create measure.

Test =
SWITCH(
    TRUE(),
     MAX('Row_Group'[Group])="MEASURE1",[Parameter_Measures],
     MAX('Row_Group'[Group])="MEASURE2",[Parameter_Measures2],
    MAX('Row_Group'[Group])="DIFFERENCE",[Parameter_Measures] - [Parameter_Measures2])

3. Result:

 

vyangliumsft_3-1709529884034.png

If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Hi my friend,

I really liked your idea, but I got a simpler solution.

The measurements are then based on a single table that isn't that big, so I made a copy of the table and created similar versions of the measurements,
like this

table 1 and measurements: 1, 2, 3
table 1a and measurements: 1a, 2a, 3a

So I created the parameters for measurements.

 

but thanks for all

Anonymous
Not applicable

Hi Greg, thanks for replay
I really don't need CALCULATE, you are right!
So, my goal is to create a row in the matrix that shows the difference between measures (single selection forced)

Presentazione standard1.jpg

 

Is there an easy way to do that?

 
Greg_Deckler
Community Champion
Community Champion

@Anonymous Well, for starters, there is no need for CALCULATE in your expression. The error seems to be referring to some other measure or something. The error is probably very dependent on the context of your visual.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.