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
Anonymous
Not applicable

Lookupvalue with multiple values in multiple tables

Still pretty new to DAX and I would so appreciate some help.   I have a pretty complex set of rules to find out a commit time for orders.   Four columns - Brand Name, Ship From, FGO.StyleCode - each of these chould be a combination of things with the fourth CO.RROStatus being either APPRVD, PEND, REJECT, or REVIEW - the only one here that will be a different return will be REJECT - it will go to a different table and return a specific lead time, the others will go to a separate table and return the lead time for the specific first three parameters in a separate table.  I have included a sample of the tables (attached) and  the way they are related , the result table I wish for the "leadtime" column to be created in and the DAX Code I have tried below to create the calculated column:

 

TotalOrders[LeadTime] = LOOKUPVALUE
    TotalOrders[LeadTime]
            RELATED(TotalOrders[Customer Brand.Brand Name], CommitPolicies[BrandID]), 
            RELATED(TotalOrders[ShipFrom], CommitPolicies[ShipFrom]), 
            RELATED(TotalOrders[Finished Goods Ordered.Door Style Code], CommitPolicies[Style]),
                IF(TotalOrders[CO.RROStatus] = "REJECT", RRORejLeadTimes[ReJectPckgLeadTime]
                        , RROLeadTimes[PckgLeadTime])
                            )

 

Each row is a separate order and I would like to have the last field (LeadTime) populated by the DAX above.

 

 

table 1.jpgRelation.jpg

If anyone has a better idea of how this should be done, I am all about it!   THANKS in advance!

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

It seems a bit complex from your description.

Let me tell you what i understand and please tell me if i'm right.

 

1.Table "TotalOrders" has relationship with table "CommitPolicies"( not directly, their relationship is via table "ShipFrom", "Customer Brand.Brand Name", "StyleUnqiue")

 

2. you want to get related column for table "TotalOrders" from table "CommitPolicies" or "RRORejLeadTimes",

when the TotalOrders[CO.RROStatus] =APPRVD, PEND, or REVIEW, it should get related column from  table "CommitPolicies",

when the TotalOrders[CO.RROStatus] =REJECT, it should get related column from  table "RRORejLeadTimes".

 

Best Regards

Maggie

 

 

 

Anonymous
Not applicable

Maggie, 

 

First thank you for looking at my issue!   You are correct in your description of the problem.    However, I have scaled the entire project down to just one report and not as many tables to simplify due to the fact I was getting a memory issue after merging the three columns Commit Times - RRORejLeadTimes and RROLeadTimes.   This allowed me to Use certain fields in the Commit policies table instead of the "pass through" tables of Styles Unique, Ship From and CustomerBrandNameUnique.  My hope is to use the CO.RROStatus field in Total Orders to filter which .....LeadTime from the CommitPolicies table.  I have screen shots to further illustrate my endeavors. 

 

I am attempting the DAX to create a calculated column:

TotalOrders[LeadTime]
    IF( TotalOrders[CO.RROStatus] = "REJECT",
        && IF( TotalOrders[CustomerBrand.BrandName] = CommitPolicies[BrandID],
        && IF( TotalOrders[ShipFrom] = CommitPolicies[ShipFrom]
        && IF( TotalOrders[FGO.StyleCode] = CommitPolicies[Style],
                [RRORejLeadTimes.ReJectPckgLeadTime]
                CommitPolicies[RROLeadTimes.PckgLeadTime]))))
 

But it doesn't really work....still new at DAX and used to using SQL....

 

Screen 1.jpgscreen 2.jpg

Hi @Anonymous

Try this measure instead

TotalOrders[LeadTime] = 
    IF( TotalOrders[CO.RROStatus] = "REJECT"
         && TotalOrders[CustomerBrand.BrandName] = CommitPolicies[BrandID],
        && TotalOrders[ShipFrom] = CommitPolicies[ShipFrom]
        && TotalOrders[FGO.StyleCode] = CommitPolicies[Style],
                [RRORejLeadTimes.ReJectPckgLeadTime], 
                CommitPolicies[RROLeadTimes.PckgLeadTime]))))

If it doesn't help, please let me know.

 

Best Regards

Maggie

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.