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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
mrothschild
Continued Contributor
Continued Contributor

Measure to fix output to a SELECTEDVALUE

PBIX file is here: https://drive.google.com/file/d/1YJ7I8PYqqEiap-mPjvprMlsLh9fv5Jkb/view?usp=sharing

 

This first screenshot has "Edit Interactions" turned off in the Matrix when the slicer is selected.

 

mrothschild_0-1683135888812.png

 

This second screenshot has the Edit Interactions between the Slicer and Matrix turned on.

 

mrothschild_1-1683135939652.png

 

The desired output will be more complicated, but as an interim step, I'd like the upper screenshot to have a matrix output equal to the SELECTEDVALUE for all rows in the Matrix.  So instead of AAA, AA+, AA, AA-, . . . on the right under the heading "Probability of Default for Reference Rating" it will be BBB, BBB, BBB, BBB, . .  ..

 

From there, I will be using SUMX to pull in the numbers in the column adjacent to it associated with the SELECTEDVALUE rather than the RowHeaders in the Matrix.  

 

I think the code is something along the lines of: 

    FILTER (
        ('_Loss Given Default'),
        '_Loss Given Default'[S&P Rating] = _Rating_Reference
    )

or

 

    FILTER (
        ALL('_Loss Given Default'),
        '_Loss Given Default'[S&P Rating] = _Rating_Reference
    )

 

 

but haven't been able to find the right solution.  

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION

Apparently, I needed a disconnected slicer to get to the desired output.  Still don't have a sufficient appreciation, and I'm confident there is a more elegant code to get to the same result, but a brute force trial & error resulted in this: 

 

Probability of Default Delta = 

VAR _SelectedRows = 
    FILTER(
        ALL('_Loss Given Default'),
        '_Loss Given Default'[S&P Rating] = SELECTEDVALUE('S&P Ratings'[S&P Rating])
    )

VAR _ReferenceRatingProbDefault = 
    SUMX(
        ADDCOLUMNS(
            VALUES('_Loss Given Default'[Month]),
            "Probability of Default", CALCULATE(
                SUM('_Loss Given Default'[Probability of Default]),
                _SelectedRows,
                '_Loss Given Default'[Month] = EARLIER('_Loss Given Default'[Month])
            )
        ),
        [Probability of Default]
    )

VAR _UnreferencedProbDefault = 
    SUMX(
        GROUPBY('_Loss Given Default','_Loss Given Default'[Month],'_Loss Given Default'[Probability of Default]),
            '_Loss Given Default'[Probability of Default]
    )

VAR _Output = 
    _UnreferencedProbDefault - _ReferenceRatingProbDefault

RETURN 
    _Output

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

you chose to disable interactions. Revert that and the table will filter as desired.

mrothschild
Continued Contributor
Continued Contributor

@lbendlin 

 

Appreciate the answer, but when I turn interactions back on, then the Matrix filters only to BBB

 

What I'd like is an output that looks like the following for this interim step:

S&P Rating[A] = Probability of Default @ Month 12[B] = Probability of Default of Selected Value @ Month 12SELECTEDVALUE[A] - [B]
AAA0.00%0.15%BBB-0.15%
AA+0.00%0.15%BBB-0.15%
AA0.02%0.15%BBB-0.13%
AA-0.03%0.15%BBB-0.12%
A+0.05%0.15%BBB-0.10%
A . . .0.05%0.15%BBB-0.10%

 

The following code is summing across ALL months as opposed to the reference month in the Matrix's Column Headers.  I suspect I need to use ALL in a different place to clear the slicer filtering, but want to keep the GROUPBY for Month association.

 

ProbDefaultRefRating = 

CALCULATE(
    SUMX(
        GROUPBY(
            '_Loss Given Default',
            '_Loss Given Default'[Month],
            '_Loss Given Default'[Probability of Default]
        ),
        '_Loss Given Default'[Probability of Default]
    ),
    ALL('_Loss Given Default'),
    '_Loss Given Default'[S&P Rating] = "BBB"
)

 

Apparently, I needed a disconnected slicer to get to the desired output.  Still don't have a sufficient appreciation, and I'm confident there is a more elegant code to get to the same result, but a brute force trial & error resulted in this: 

 

Probability of Default Delta = 

VAR _SelectedRows = 
    FILTER(
        ALL('_Loss Given Default'),
        '_Loss Given Default'[S&P Rating] = SELECTEDVALUE('S&P Ratings'[S&P Rating])
    )

VAR _ReferenceRatingProbDefault = 
    SUMX(
        ADDCOLUMNS(
            VALUES('_Loss Given Default'[Month]),
            "Probability of Default", CALCULATE(
                SUM('_Loss Given Default'[Probability of Default]),
                _SelectedRows,
                '_Loss Given Default'[Month] = EARLIER('_Loss Given Default'[Month])
            )
        ),
        [Probability of Default]
    )

VAR _UnreferencedProbDefault = 
    SUMX(
        GROUPBY('_Loss Given Default','_Loss Given Default'[Month],'_Loss Given Default'[Probability of Default]),
            '_Loss Given Default'[Probability of Default]
    )

VAR _Output = 
    _UnreferencedProbDefault - _ReferenceRatingProbDefault

RETURN 
    _Output

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.