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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.

June 2025 community update carousel

Fabric Community Update - June 2025

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