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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
M_Ulloa
Frequent Visitor

Measure using slicer value in two different ways

Hi data gurus,

 

I have an issue that I'm hoping one of you may be able to help with. With the following test data:

 

Initiating OrgEnding OrgCount
AB1
BB32
CB1
DB3
EB2
FB1
BC2
BG1
BE10
BF1

 

I have a slicer on "Ending Org" and two measures:

 

Measure1: CALCULATE([Count], FILTER(myTable, myTable[Initiating Org] = myTable[Ending Org]))
Measure2: CALCULATE([Count], FILTER(myTable, myTable[Initiating Org] <> myTable[Ending Org]))
 
These plot correctly on a table visual. The issue is that I want to somehow show where Initiating Org <> Ending Org, but taking into consideration the Initiating Org, so the table visual when filtered for Ending Org B, shows the last 4 lines, where it's the "Initiating Org". I've been able to get the count to work with:

Measure3: CALCULATE([Count], FILTER(ALL(myTable),
myTable[Initiating Org] = SELECTEDVALUE(myTable[Ending Org]) &&
myTable[Ending Org] <> SELECTEDVALUE(myTable[Ending Org]) ) )
 
But this doesn't plot correctly in a table or matrix visual as it shows the total result (14) in all rows. The expected result would be:
 
Initiating OrgEnding OrgCountMeasure 1Measure 2Measure 3
AB1 1 
BB3232  
CB1 12
DB3 3 
EB2 210
FB1 11
BG1  1
  4132814
 
Any help is greatly appreciated! I would have attached a dummy .pbix, but Microsoft doesn't allow such things for "new" users, even though I've been registered in this forum since 2020.
1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @M_Ulloa ,

Thanks for the detailed explanation and example—this is a classic scenario where context transition in DAX can trip things up, especially when working with slicers and row context in visuals. The issue with your Measure3 returning the same value across all rows stems from the use of SELECTEDVALUE, which doesn't behave as expected when used in a row-level evaluation within a table visual. Instead, you’ll want to leverage the current row context to dynamically reference the “Initiating Org” rather than relying solely on the slicer’s value.

 

One approach is to use VALUES or directly reference the row context using myTable[Initiating Org] in your measure. Try modifying Measure3 like this:

Measure3 = 
CALCULATE(
    [Count],
    FILTER(
        ALL(myTable),
        myTable[Initiating Org] = EARLIER(myTable[Initiating Org]) &&
        myTable[Ending Org] = SELECTEDVALUE(myTable[Ending Org]) &&
        myTable[Initiating Org] <> myTable[Ending Org]
    ))

 

Alternatively, consider using a calculated column if you're looking to simplify row-level logic. If EARLIER doesn't quite solve it, using variables to explicitly capture the row-level values might be more reliable in a measure context. Let me know if you'd like help rewriting it that way. You're on the right track, and with a small tweak to respect row context, your visual should display as expected.

 

Passionate about leveraging data analytics to drive strategic decision-making and foster business growth.

Connect with me on LinkedIn: Rohit Kumar.

View solution in original post

5 REPLIES 5
v-priyankata
Community Support
Community Support

Hi @M_Ulloa 
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

v-priyankata
Community Support
Community Support

Hi @M_Ulloa 
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-priyankata
Community Support
Community Support

Hi @M_Ulloa 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

rohit1991
Super User
Super User

Hi @M_Ulloa ,

Thanks for the detailed explanation and example—this is a classic scenario where context transition in DAX can trip things up, especially when working with slicers and row context in visuals. The issue with your Measure3 returning the same value across all rows stems from the use of SELECTEDVALUE, which doesn't behave as expected when used in a row-level evaluation within a table visual. Instead, you’ll want to leverage the current row context to dynamically reference the “Initiating Org” rather than relying solely on the slicer’s value.

 

One approach is to use VALUES or directly reference the row context using myTable[Initiating Org] in your measure. Try modifying Measure3 like this:

Measure3 = 
CALCULATE(
    [Count],
    FILTER(
        ALL(myTable),
        myTable[Initiating Org] = EARLIER(myTable[Initiating Org]) &&
        myTable[Ending Org] = SELECTEDVALUE(myTable[Ending Org]) &&
        myTable[Initiating Org] <> myTable[Ending Org]
    ))

 

Alternatively, consider using a calculated column if you're looking to simplify row-level logic. If EARLIER doesn't quite solve it, using variables to explicitly capture the row-level values might be more reliable in a measure context. Let me know if you'd like help rewriting it that way. You're on the right track, and with a small tweak to respect row context, your visual should display as expected.

 

Passionate about leveraging data analytics to drive strategic decision-making and foster business growth.

Connect with me on LinkedIn: Rohit Kumar.

Irwan
Super User
Super User

hello @M_Ulloa 

 

please check if this accomodate your need.

Irwan_0-1744091320600.png

although i am not sure why you have G in your expected result screenshot if the screenshot showed B value in EndingOrg slicer.

 

also i am not sure the meaning of measure 3. you want to calculate value when InitiatingOrg is equal to EndingOrg and InitiatingOrg is not equal to EndingOrg. Seems conflicting.

 

Hope this will help.

Thank you.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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