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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Hero11
New Member

Multiple Conditions into 1 Calculated Column

Need some help to finish some DAX.  I have 2 Tables (A & B).  On Table-A, I have various columns one of which is a Column (TurnArounds) that lists turnaround times by day type: Expedited, Calendar Days, Working Days.  Table-B, contains 3 separate calculated columns corresponding to each turnaround type.  Both tables are linked by a primary identifier.

Table_A Example:

Unique_IDTurnAroundsGrab DueDate (new col)
123Expedited 
456Calendar Days 
789Working Days 
012Expedited 

 

I want to return the values (calculated date values) from Table-B to Table-A in a new single column, based on a match of the ID & TurnArounds Column listed on each row in Table-A.  One date for each row in the new column on Table_A.

Table_B Example:

Unique_IDDue_Date_TypesExpeditedCalendar DaysWorking Days
012Expedited1/1/20252/1/20253/1/2025
789Working Days

1/5/2025

2/5/20253/13/2025
123Expedited1/10/20252/15/20253/31/2025
456Calendar Days1/20/20252/24/20254/1/2025

 

 I started writing some DAX, that works for only one TurnAround scenario at a time, but not all 3. Can i please get some help to fill in Table_A?  Hopefully I was sort of on the right path as I'm still relatively new to PowerBI.  Thanks in advance.

 

Grab DueDate =

VAR vTrackNumber = 'Table_A'[UniqueID]

VAR vTable = FILTER('Table_B', 'Table_B'[UniqueID] = vTrackNumber

                      && 'Table_B'[Due_Date_Types] = {"Business Days", "Calendar Days", "Expedited"})

 

RETURN

                    CALCULATE(SELECTEDVALUE('Table_B'[Working_Days_Column]))

1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @Hero11  Try the below code:

Grab DueDate = 
VAR CurrentID = 'Table A'[Unique_ID]
VAR CurrentTurnAround = 'Table A'[TurnArounds]
RETURN
SWITCH(
    CurrentTurnAround,
    "Expedited", LOOKUPVALUE('Table B'[Expedited], 'Table B'[Unique_ID], CurrentID),
    "Calendar Days", LOOKUPVALUE('Table B'[Calendar Days], 'Table B'[Unique_ID], CurrentID),
    "Working Days", LOOKUPVALUE('Table B'[Working Days], 'Table B'[Unique_ID], CurrentID),
    BLANK()
)

 

Here is the expected result:

shafiz_p_0-1738558484271.png

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

6 REPLIES 6
divyed
Super User
Super User

Hello @Hero11 ,

 

Please use below dax which will give you corresponding due_Dates. It will give you dates if available and leave blank if there is no matching values in table2 so you will have all rows from table1 and matching values from table2 . 

 

Grab DueDate =
VAR CurrentID = 'Tab_1'[Unique_ID]
VAR CurrentTurnAround = 'Tab_1'[TurnAround]
VAR ExpeditedDate = LOOKUPVALUE('Tab_2'[Expedited], 'Tab_2'[Unique_ID], CurrentID)
VAR CalendarDate = LOOKUPVALUE('Tab_2'[Calendar Days], 'Tab_2'[Unique_ID], CurrentID)
VAR WorkingDaysDate = LOOKUPVALUE('Tab_2'[Working Days], 'Tab_2'[Unique_ID], CurrentID)
RETURN
    SWITCH(
        TRUE(),
        CurrentTurnAround = "Expedited" && NOT ISBLANK(ExpeditedDate), ExpeditedDate,
        CurrentTurnAround = "Calendar Days" && NOT ISBLANK(CalendarDate), CalendarDate,
        CurrentTurnAround = "Working Days" && NOT ISBLANK(WorkingDaysDate), WorkingDaysDate,
        BLANK()  -- If no match or date not found
    )
 
I hope this will work, if not kindly share expected output to check further.
divyed_0-1738672051265.png

 

Did I answer your query ? Mark this as solution if this helps , Kudos are appreciated.

 

Warm Regards,

Neeraj

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/
Hero11
New Member

Hi @shafiz_p ,

 

Thank you first of all for your prompt response.  Okay, I plugged in your code into a new Calculated Column on Table_A and it kind or worked.  It returned a date value for my Expedited days as expected, but returned Blanks for both Calendar & Business Days.  Reading the code it looks like it logically validates the Unique_ID & TurnArounds day types.  Looks so promising.  Any suggestions? 

 

Additional info: Table_B is comprised of the same date data for all 3 types of TurnArounds: Calendar, Business, Calendar.  The 2 Tables are linked with a 1:1 Relationship.  When I substitue the RETURN part of my sample code to be specific to Calendar or Business or Expedited it does provide a date on Table_A.  It doesn't work for all 3 simultaneously. Was trying to test the values in Table_B, but it seems it returns the values in some instances when I use my old code. For example:

     ... 

     RETURN

     CALCULATE(SELECTEDVALUE('Table_B'[Working Days]))

--top works for working days only & same thing if I call out Calendar Days specifically

 

I'll try to keep hammering away at it.  Let me know if you have any alternate suggestions/thoughts/ideas.  Greatly appreciate any feedback.

Anonymous
Not applicable

Hi ALL,
Firstly  shafiz_p  thank you for your solution!
And @Hero11 ,
Based on your current problem, you may not be able to return the values of the other date columns correctly right?
Since your primary keys are concatenated on a one-to-one or one-to-many basis, then we recommend that you use the realted function to get the values that you need to accomplish what you need to do.

Grab DueDate = 
SWITCH(
    Table_A[TurnArounds],
    "Expedited", RELATED(Table_B[Expedited]),
    "Calendar Days", RELATED(Table_B[Calendar Days]),
    "Working Days", RELATED(Table_B[Working Days])
)

vxingshenmsft_0-1738634126248.png

I hope my code is helpful and I would be honored if it solves your problem!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

Hey @Anonymous ,

Looks like the same outcome.  It returns the type Expedited, but blanks for both Calendar Days or Business Days.  You're correct, the Tables have a One-to-One relationship connected by the Unique_ID (primary key).  Thank you for the input.  Can I provide any additional info that would help figure out the issue?

Anonymous
Not applicable

Hi @Hero11 ,
Can you provide some example data or some pbix files so that we can better help you to solve the problem, you can upload your pbix files in the form of web storage so that we can better help you to solve the problem!

shafiz_p
Super User
Super User

Hi @Hero11  Try the below code:

Grab DueDate = 
VAR CurrentID = 'Table A'[Unique_ID]
VAR CurrentTurnAround = 'Table A'[TurnArounds]
RETURN
SWITCH(
    CurrentTurnAround,
    "Expedited", LOOKUPVALUE('Table B'[Expedited], 'Table B'[Unique_ID], CurrentID),
    "Calendar Days", LOOKUPVALUE('Table B'[Calendar Days], 'Table B'[Unique_ID], CurrentID),
    "Working Days", LOOKUPVALUE('Table B'[Working Days], 'Table B'[Unique_ID], CurrentID),
    BLANK()
)

 

Here is the expected result:

shafiz_p_0-1738558484271.png

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

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.