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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BigFella
Regular Visitor

If Column A equals X, then return value from Column B; If Column B is blank, return "Text"

I have a table, "PlannerTaskInformation", in BI that pulls project data from Microsoft Planner. I'm trying to create a measure that returns the value of the TaskCompletedDate column, if the Tasks column equals "On Hold". This much I was able to do using the following:

On Hold - Completed Date =
CALCULATE(
MAX('PlannerTaskInformation'[TaskCompletedDate]),
FILTER(PlannerTaskInformation, PlannerTaskInformation[Tasks] = { "On Hold" } ))


Now I'd like to add one more layer to that. If the Task column equals "On Hold", but the TaskCompletedDate column is blank, I'd like to return the text "Active"

PROJECTTASKTASKCOMPLETEDDATEDESIRED MEASURE OUTPUT
BClean Up Items  
BDesign  
BPhase 1: Set-Up07/28/2020 
BPhase 2: Velocity01/12/2021 
BPhase 3: Testing and Retesting07/27/2020 
BPhase 4: Deployment01/12/2021 
BPhase 5: Maintenance01/12/2021 
BOn Hold01/12/202101/12/2021
CClean Up Items  
CDesign  
CPhase 1: Set-Up  
CPhase 2: Velocity01/13/2021 
CPhase 3: Testing and Retesting12/15/2020 
CPhase 4: Deployment  
CPhase 5: Maintenance  
COn Hold Active

 

I tried to do something using SWITCH, but was unsuccessful. This will no doubt reveal what a BI novice I am, but it's as far as I could take it. Thanks in advance!

On Hold - Completed Date =
SWITCH (
TRUE (),
MAX(PlannerTaskInformation[Tasks] = "On Hold" && MAX('PlannerTaskInformation'[TaskCompletedDate]) <> BLANK(), PlannerTaskInformation'[TaskCompletedDate],
MAX(PlannerTaskInformation[Tasks] = "On Hold" && MAX('PlannerTaskInformation'[TaskCompletedDate]) = BLANK(), "Active")

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@BigFella This should be straight forward, add a column:

 

Desired Output Column = 
IF ( 
Table[Task] = "On Hold", 
IF ( ISBLANK ( Table[TaskcompletedDate] ) , "Active", FORMAT(Table[TaskCompleteDate], "MM/dd/yyyy" ) 
)
)

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
BigFella
Regular Visitor

@parry2k When I use this new column in conjunction with another measure, I'm running into an issue. I have a "Project Risks" table visual that needs to show both Unassigned Tasks and the On Hold Completed Date on a single row per project. 


As noted above, the On Hold Completed column uses "Active" if the TaskCompletedDate column is blank, and the date from the TaskCompletedDate column if its populated. Unassigned Tasks is the measure below: 

Unassigned Tasks =
CALCULATE(COUNTBLANK('PlannerTaskInformation'[Task Assigned User]),
FILTER(PlannerTaskInformation, PlannerTaskInformation[TaskCompletedDate] = BLANK() ))

Because the measure filters for when TaskCompletedDate is blank, and the On Hold Completed column can include instances where TaskCompletedDate is not blank, I can't get these on a single row. Instead I end up with this:

Project   OnHold-StartDate   TaskCompletedDate   OnHold-CompletedColumn   UnassignedTasks   
A   1
B01/07/21 Active1
C   3
C11/18/2001/13/211/13/2021 
D   2


When what I want is this:

Project   OnHold-StartDate   TaskCompletedDate   OnHold-CompletedColumn   UnassignedTasks   
A   1
B01/07/21 Active1
C11/18/2001/13/211/13/20213
D   2

*(The final table will not show TaskCompletedDate, that is included in this example for illustrative purposes only)

 

Is there a way to get these two columns to play nice and condense data to a single row per project? I tried rewriting the measure as shown below, but it gave me the same result:
Unassigned Tasks =
CALCULATE(COUNTBLANK('PlannerTaskInformation'[Task Assigned User]),
PlannerTaskInformation[TaskCompletedDate] = BLANK() )

Thank you

parry2k
Super User
Super User

@BigFella This should be straight forward, add a column:

 

Desired Output Column = 
IF ( 
Table[Task] = "On Hold", 
IF ( ISBLANK ( Table[TaskcompletedDate] ) , "Active", FORMAT(Table[TaskCompleteDate], "MM/dd/yyyy" ) 
)
)

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I had picked up in my self-taught BI crash course that measures were preferred, so I was trying to force it as such, but the column definitely worked like a charm here. Thanks a million, and thanks for all the other answers on this forum too, I've learned a lot just cruising these posts!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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