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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
raj302016
New Member

DAX formula IF measure returns null value then search ID and match with another table ID

I need Expert support on below query.

I've made below table using existing datasets and measures, which gives me SW_PART value against each of opportunity using multiple criteria.
Now, I want next level DAX calculation to merge/show single row which is first row, the calculation should give me second row result into First row, I mean value 5720 (under OPP-10225) -should be visible/copy to OPP-10236 and later I will hide the OPP-10225 from the table visual.

SW_PART is already a measure

Opportunity IDOpportunity NameEnd Customer NameSW_PART
OPP-10236VD OPS_SupportApple 
OPP-10225VD OPSApple5720
OPP-10237MD OPS_SupportMS 
OPP-10226MD OPSMS8890
OPP-10238DD OPS_SupportVirgin 
OPP-10227DD OPSVirgin23345



To identify the correct opportunity ID, I've made below excel table, which I've already imported to PowerBI.
This table help to identify the which NULL Opportunity ID from above table matches Original OPP_ID to this table then search Product OPP_ID = Opportunity ID and get the value or calculate value then return the value against Opportunity ID

Original Opp_IDProduct OPP_IDProduct Quote_PK Quote ID
OPP-10236OPP-10225TST-0246937D1E2089-3CF9-ED11-8F6E-6045BD11F57A
OPP-10108OPP-10425TST-025442BFB78603-F7B8-ED11-B596-00224801E567


I've used below DAX but it's showing same values in against all NULL opportunities

SW_PART_Filled =
VAR ValuefromOPP_ID =
    CALCULATE(
        [SW_PART],
        FILTER(
            ALL('Quote Details - All Records'),
            'Quote Details - All Records'[_FK Quote ID] = MAX('VN-OPP Identifier'[_PK Quote ID])
        )
       
    )
RETURN
    IF(
        ISBLANK([SW_PART]),
        ValuefromOPP_ID,
        [SW_PART]
    )

Results I am getting as below, which showing same results against opportunity

Opportunity IDOpportunity NameEnd Customer NameSW_PART
OPP-10236VD OPS_SupportApple5720
OPP-10225VD OPSApple5720
OPP-10237MD OPS_SupportMS5720
OPP-10226MD OPSMS8890
OPP-10238DD OPS_SupportVirgin5720
OPP-10227DD OPSVirgin23345


1 ACCEPTED SOLUTION
xifeng_L
Super User
Super User

Hi @raj302016 

 

You can refer to below measure.

 

SW_PART_Filled = 
VAR ProdOppID = LOOKUPVALUE('VN-OPP Identifier'[Product OPP_ID],'VN-OPP Identifier'[Original Opp_ID],MAX('Quote Details'[Opportunity ID]))
VAR TempTbl = 
    CALCULATETABLE(
        ADDCOLUMNS(
            SUMMARIZE(
                'Quote Details',
                'Quote Details'[Opportunity ID],
                'Quote Details'[Opportunity Name],
                'Quote Details'[End Customer Name]
            ),
            "SW_PART",
                [SW_PART_Measure]
        ),
        ALLSELECTED()
    )
RETURN
MAXX(
    FILTER(TempTbl,'Quote Details'[Opportunity ID]=ProdOppID),
    [SW_PART]
)

 

xifeng_L_0-1724775465479.png

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

View solution in original post

3 REPLIES 3
raj302016
New Member

@xifeng_L - Thank you for the solution.

 

The DAX is working fine but when I trying to hide this OPP-10225 the calculation also removed from OPP-10236 as highlighted below. I don't want to show duplicate figures on row lables and Grand total also.

As I mentioned in my initial thread that once DAX calculates the figures and show against OPP.... then I will hide the previous OPP from the table visual but calculated figures remains there.

raj302016_0-1724818302445.png

 

Thanks,

 

I've made some changes. You can try again.

 

SW_PART_Filled = 
SUMX(
    VALUES('Quote Details'[Opportunity ID]),
    VAR ProdOppID = LOOKUPVALUE('VN-OPP Identifier'[Product OPP_ID],'VN-OPP Identifier'[Original Opp_ID],'Quote Details'[Opportunity ID])
    RETURN
    CALCULATE(
        [SW_PART_Measure],
        'Quote Details'[Opportunity ID]=ProdOppID,
        ALL('Quote Details'[Opportunity Name],'Quote Details'[End Customer Name])
    )
)

 

xifeng_L_0-1724857125480.png

 

xifeng_L
Super User
Super User

Hi @raj302016 

 

You can refer to below measure.

 

SW_PART_Filled = 
VAR ProdOppID = LOOKUPVALUE('VN-OPP Identifier'[Product OPP_ID],'VN-OPP Identifier'[Original Opp_ID],MAX('Quote Details'[Opportunity ID]))
VAR TempTbl = 
    CALCULATETABLE(
        ADDCOLUMNS(
            SUMMARIZE(
                'Quote Details',
                'Quote Details'[Opportunity ID],
                'Quote Details'[Opportunity Name],
                'Quote Details'[End Customer Name]
            ),
            "SW_PART",
                [SW_PART_Measure]
        ),
        ALLSELECTED()
    )
RETURN
MAXX(
    FILTER(TempTbl,'Quote Details'[Opportunity ID]=ProdOppID),
    [SW_PART]
)

 

xifeng_L_0-1724775465479.png

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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