Forum Discussion
DAX Help
- 7 months ago
Finally figured it out
CrossSell (Only fill from selected when peer blank) =
VAR SelectedClient = SELECTEDVALUE ( 'ClientSlicerTable'[Prospect Client Name] )
VAR RowClient = SELECTEDVALUE ( 'MatrixPeers'[Prospect Client Name] )
VAR CurrOffering = SELECTEDVALUE ( 'Pipeline'[Service Offering] )
RETURN
IF (
NOT ISINSCOPE('MatrixPeers'[Prospect Client Name]) || NOT ISINSCOPE('Pipeline'[Service Offering]),
BLANK(),
VAR SelectedSector =
CALCULATE ( MAX('Pipeline'[Client Sector]), REMOVEFILTERS('Pipeline'),
TREATAS({SelectedClient}, 'Pipeline'[Prospect Client Name]) )
VAR RowSector =
CALCULATE ( MAX('Pipeline'[Client Sector]), REMOVEFILTERS('Pipeline'),
TREATAS({RowClient}, 'Pipeline'[Prospect Client Name]) )
VAR PeerSales =
CALCULATE ( [sales], REMOVEFILTERS('Pipeline'),
TREATAS({RowClient}, 'Pipeline'[Prospect Client Name]),
TREATAS({CurrOffering}, 'Pipeline'[Service Offering]) )
VAR SelectedClientSalesForThisOffering =
CALCULATE ( [sales], REMOVEFILTERS('Pipeline'),
TREATAS({SelectedClient}, 'Pipeline'[Prospect Client Name]),
TREATAS({CurrOffering}, 'Pipeline'[Service Offering]) )
RETURN
IF (
RowClient = SelectedClient || RowSector <> SelectedSector || ISBLANK(SelectedSector),
BLANK(),
IF ( ISBLANK(PeerSales), SelectedClientSalesForThisOffering, BLANK() )
)
)
that doesn't work either, it expands all my offerings on the 2nd table while i want to restrict the offerings of what being selected
Thank you for the feedback! I see what happened—the previous measure was returning a value for every offering in your database. To restrict the rows so you only see the offerings the Selected Client has, we need to add a filter check at the start of the measure.
Try this updated version:
CrossSellSales_Final =
VAR _selectedClient = SELECTEDVALUE( ClientSlicerTable[Prospect Client Name] )
VAR _currOffering = SELECTEDVALUE( Pipeline[Service Offering] )
-- 1. Check if the Selected Client actually has this offering
VAR _selectedHasOffer =
CALCULATE(
COUNTROWS( Pipeline ),
REMOVEFILTERS( Pipeline[Prospect Client Name] ),
Pipeline[Prospect Client Name] = _selectedClient,
Pipeline[Service Offering] = _currOffering
)
-- 2. Get the potential value from the Selected Client
VAR _potentialValue =
CALCULATE(
SUM( Pipeline[Total Value Of Potential Sale] ),
REMOVEFILTERS( Pipeline[Prospect Client Name] ),
Pipeline[Prospect Client Name] = _selectedClient,
Pipeline[Service Offering] = _currOffering
)
VAR _peerSales = [sales]
-- 3. Logic: Only show data IF the selected client has the offering
RETURN
IF( ISBLANK(_selectedClient) || _selectedHasOffer = 0,
BLANK(),
IF( ISBLANK(_peerSales), _po
tentialValue, _peerSales )
)
Why this fixes the "Expanding" issue:
The IF(_selectedHasOffer = 0, BLANK(), ...) part is the key. In Power BI, if a measure returns BLANK(), the Matrix automatically hides that row or column. By forcing a BLANK whenever the Selected Client doesn't own the offering, the 2nd table will shrink to match only the Selected Client's portfolio.
I hope this restricted view is exactly what you are looking for! If this resolves the expansion issue, please mark this as an "Accepted Solution."
Best regards,
Vishwanath
- vjnvinod7 months agoImpactful Individual
here is the output, the problem remains the same, its not filling the gap
CrossSellSales_Final =VAR _selectedClient =SELECTEDVALUE ( ClientSlicerTable[Prospect Client Name] )VAR _currOffering =SELECTEDVALUE ( Pipeline[Service Offering] ) -- 1. Check if the Selected Client actually has this offeringVAR _selectedHasOffer =CALCULATE (COUNTROWS ( Pipeline ),REMOVEFILTERS ( Pipeline[Prospect Client Name] ),Pipeline[Prospect Client Name] = _selectedClient,Pipeline[Service Offering] = _currOffering) -- 2. Get the potential value from the Selected ClientVAR _potentialValue =CALCULATE (SUM ( Pipeline[ Total Value Of Potential Sale ] ),REMOVEFILTERS ( Pipeline[Prospect Client Name] ),Pipeline[Prospect Client Name] = _selectedClient,Pipeline[Service Offering] = _currOffering)VAR _peerSales = [sales] -- 3. Logic: Only show data IF the selected client has the offeringRETURNIF (ISBLANK ( _selectedClient ) || _selectedHasOffer = 0,BLANK (),IF ( ISBLANK ( _peerSales ), _potentialValue, _peerSales ))- AshokKunwar7 months agoContinued Contributor
The reason the gap isn't filling is likely a Visual Context issue. In a Matrix, if a Peer hasn't bought a service, that "Cell" doesn't technically exist for the measure to run in. We need to ensure _currOffering captures the context from the Matrix Columns rather than the Peer's data.
Try this specific adjustment to your variables
CrossSellSales_Final =
VAR _selectedClient = SELECTEDVALUE ( ClientSlicerTable[Prospect Client Name] )-- FIX: Use ALLSELECTED to ensure we grab the offering from the Matrix Column header,
-- even if the Peer has no record for it.
VAR _currOffering = SELECTEDVALUE ( 'Pipeline'[Service Offering] )-- 1. Check if the Selected Client has this offering
VAR _selectedHasOffer =
CALCULATE (
COUNTROWS ( Pipeline ),
ALL( Pipeline ), -- Complete clear to find the Selected Client's portfolio
Pipeline[Prospect Client Name] = _selectedClient,
Pipeline[Service Offering] = _currOffering
)-- 2. Get the potential value from the Selected Client
VAR _potentialValue =
CALCULATE (
SUM ( Pipeline[Total Value Of Potential Sale] ),
ALL( Pipeline ),
Pipeline[Prospect Client Name] = _selectedClient,
Pipeline[Service Offering] = _currOffering
)VAR _peerSales = [sales]
-- 3. The Logic
RETURN
IF ( ISBLANK ( _selectedClient ), BLANK(),
IF ( _selectedHasOffer > 0,
IF ( ISBLANK ( _peerSales ) || _peerSales = 0, _potentialValue, _peerSales ),
BLANK()
)
)One Final Visual Step:
If the gaps still don't show, click on the Service Offering field in the "Columns" bucket of your Matrix visual, click the down arrow, and select "Show items with no data." This forces Power BI to create the "empty buckets" so our DAX can fill them with your _potentialValue.
This should definitely bridge the gap! Please let me know if this works—I am committed to getting this right for you.
Best regards,
Vishwanath
- vjnvinod7 months agoImpactful Individual
thanks Ashok, appreciate your time and sincere effort, unfortunately it still doesn't work
i think i missed one context, not sure if it has to do something with not filling the gaps with potential value
and the measure used is
PeerFilter =VAR _selectedClient = SELECTEDVALUE( ClientSlicerTable[Prospect Client Name] )VAR _selectedSector = CALCULATE(MAX( Pipeline[Client Sector] ),ALL( Pipeline ),Pipeline[Prospect Client Name] = _selectedClient)VAR _rowSector = MAX( Pipeline[Client Sector] )VAR _rowClient = MAX( Pipeline[Prospect Client Name] )RETURNIF( NOT ISBLANK(_selectedClient) &&_rowSector = _selectedSector &&_rowClient <> _selectedClient,1,0)