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
J89
Frequent Visitor

Using values from sliced measures in other measures

Hi all,

 

I'm new to Power BI. Hoping someone might be able to help me with the below problem. I've tried to search for the answers but nothing I find seems to work. Maybe I'm not searching for the right phrases.

 

The background:

 

  • I have a base data set
  • I have created 'Measure 1' from the base data set, which shows the percentage of the people who have taken action Y
  • I have created 'Slicers 1' (a group of slicers) which allows the user to apply filters to Measure 1 only
  • I have created 'Measure 2' from the base data set, which shows the percentage of the people who have taken action Y
  • I have created 'Slicers 2' (a group of slicers) which allows the user to apply filters to Measure 2 only

The problem

 

I now want to create 'Measure 3', which displays 'Measure 1 - Measure 2'. Measure 3 should change depending on what the user has selected in Slicers 1 and Slicers 2.

 

I can't seem to find the answer. Any ideas? I am Power BI/DAX novice, so please assume I know nothing about the platform when suggesting an answer.

 

Many thanks,

 

J89

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @J89 ,

 

There are many other factors that you haven't clarified clearly, such as whether your slicer fields are all from the same table? What are your specific formulas for measure 1 and measure 2? If you can, please provide some sample data (some tabular type data), as well as the desired results.

I made a sample and don't know if it matches your situation.

Sample data

vstephenmsft_0-1675132184892.png

Slicer1 and Slicer2 are calculated tabls.

vstephenmsft_1-1675132218635.png

vstephenmsft_2-1675132227791.png

There're no relationships among three tables.

vstephenmsft_3-1675132270949.png

Measure1 = CALCULATE(SUM('Table'[percentage]),FILTER(ALLSELECTED('Table'),[year]=SELECTEDVALUE(Slicer1[year])&&[action]="Y"))
Measure2 = CALCULATE(SUM('Table'[percentage]),FILTER(ALLSELECTED('Table'),[year]=SELECTEDVALUE(Slicer2[year])&&[action]="Y"))
Measure3 = [Measure1]-[Measure2]

vstephenmsft_4-1675132374102.png

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @J89 ,

 

There are many other factors that you haven't clarified clearly, such as whether your slicer fields are all from the same table? What are your specific formulas for measure 1 and measure 2? If you can, please provide some sample data (some tabular type data), as well as the desired results.

I made a sample and don't know if it matches your situation.

Sample data

vstephenmsft_0-1675132184892.png

Slicer1 and Slicer2 are calculated tabls.

vstephenmsft_1-1675132218635.png

vstephenmsft_2-1675132227791.png

There're no relationships among three tables.

vstephenmsft_3-1675132270949.png

Measure1 = CALCULATE(SUM('Table'[percentage]),FILTER(ALLSELECTED('Table'),[year]=SELECTEDVALUE(Slicer1[year])&&[action]="Y"))
Measure2 = CALCULATE(SUM('Table'[percentage]),FILTER(ALLSELECTED('Table'),[year]=SELECTEDVALUE(Slicer2[year])&&[action]="Y"))
Measure3 = [Measure1]-[Measure2]

vstephenmsft_4-1675132374102.png

 

 

Best Regards,

Stephen Tao

 

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

Hi @v-stephen-msft 

 

Thank you for taking the time to explain this so clearly with examples. Your solution worked perfectly.

 

I think the problems I was experiencing were two-fold.

 

Firstly, I wasn't using seperate tables for slicers. All the information was in one table - example below

Table 1

ID

ACTION TAKEN

 

(The criteria being calculated)

YEAR OF BIRTH

 

(The vlaues being used in the slicer

1Y2000
2Y1999
3N1998

 

The second issue was that Measure 1 and Measure 2 were not referencing the non-existent slicer tables in their formulas.

 

Original incorrect formulas example:

 

Measure 1 = (CALCULATE(COUNT('Table 1'[ACTION TAKEN]),'TABLE 1'[ACTION TAKEN]="Y")/(COUNT('TABLE 1'[ACTION TAKEN]))

 

Measure 2 = (CALCULATE(COUNT('Table 1'[ACTION TAKEN]),'TABLE 1'[ACTION TAKEN]="Y")/(COUNT('TABLE 1'[ACTION TAKEN]))

 

Measure 3 = Measure 1 - Measure 2

 

My formulas now mirror those you have set out and, as I've said, it works perfectly.

 

Thank you

 

J89

 

J89
Frequent Visitor

For context, the intention it to allow the user to compare different groups of people who have taken action Y and see the difference in Measure 3

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.