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
samlopez313
Microsoft Employee
Microsoft Employee

Getting row level context to DAX formula

Hi I have a pivot table that has a rows as Area and then SubArea. 

 

samlopez313_1-1614188467658.png

 

I'm creating a URL that has the Area on the link concatenated, but I want to use the subarea when needed, e.g. when a user expands the area and the row level context changes to the SubArea. Is there a way to do this? 
E.g. when the field is collapsed at the Area level the URL would be: https://contoso.apac.com/ (this I was able to do) but when the field is expanded to SubArea I want the URL to be: https://contoso.brunei.com/  (currently is just https://constoso.apac.com/ at this level too).


Is there a way to know at what level you are drilled down to? Then I could create an IF statement to select the correct column to contatenate. Or is there a way to use the value from the "Rows" of the pivot table to concatenate? 

 

Thanks.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

This is a situation where ISINSCOPE is useful.

 

You could use it like this:

Context =
IF (
    ISINSCOPE ( Table1[SubArea] ),
    SELECTEDVALUE ( Table1[SubArea] ),
    SELECTEDVALUE ( Table1[Area] )
)

 

View solution in original post

6 REPLIES 6
samlopez313
Microsoft Employee
Microsoft Employee

Hi Alexis,

 

I'm trying the solution above but it just returns blank, making the URL like: https://contoso..com with no area or subarea, do you know why this might be? I'll add more details in a bit. It's like SELECTEDVALUE is not returning anything. 

What does your existing measure look like?

I'm creating this as a column and this is the formula: 

URL = 
VAR context = IF(ISINSCOPE(Table1[Area]),SELECTEDVALUE(Table1[Area]),SELECTEDVALUE(Table1[SubArea]))
RETURN
CONCATENATE(CONCATENATE("https://contoso.",context),".com")

 This is the current result:

samlopez313_0-1614191428256.png

As you can see the hyperlink is not concatenated correctly as it seems that "context" is empty. If I collapse the fields to the Area level it behaves the same. 

I meant the measure you had that just worked with just the Area. What does that look like?

 

Note that I wouldn't expect the expression I gave to work as a calculated column (since the scope is created by the visual). It has to be a measure.

Got it, yes! While you were responding I created the measure instead of the column and this is working great! Thanks! 

AlexisOlson
Super User
Super User

This is a situation where ISINSCOPE is useful.

 

You could use it like this:

Context =
IF (
    ISINSCOPE ( Table1[SubArea] ),
    SELECTEDVALUE ( Table1[SubArea] ),
    SELECTEDVALUE ( Table1[Area] )
)

 

Helpful resources

Announcements
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!

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.

Top Solution Authors