The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
This second screenshot has the Edit Interactions between the Slicer and Matrix turned on.
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!
Solved! Go to 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
you chose to disable interactions. Revert that and the table will filter as desired.
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 12 | SELECTEDVALUE | [A] - [B] |
AAA | 0.00% | 0.15% | BBB | -0.15% |
AA+ | 0.00% | 0.15% | BBB | -0.15% |
AA | 0.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