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
Rajat
Frequent Visitor

Retrive a value from multiple matching records

 

Project Master                                                                                         Task Allocation

 

ProjectID  projectName  Project Status                                                 Task ID   ProjectiD  Task status

  P1            A                                                                                           T1          P1           Completed

  P2            B                                                                                           T2          P1            In progress

  P3            C                                                                                           T3          P1            Completed

                                                                                                                T4          P2           Inprogress

                                                                                                                T5          P2           Completed

                                                                                                                T6          P2           In progress

 

 

I need to update "Project status" in Project Master in such a way that if any of the task of Project is in progress then we need to update "Project status"  as "In progress" othervise "Completed".

 

Can any one tell me, how to approach this problem.

 

I tried it with LookupValue(),but is works only for one matching record.But here are multiple matching record.

4 REPLIES 4
Greg_Deckler
Super User
Super User

@Rajat, First, please do not cross-post in every forum, that's not cool. A lot of us use the "All Topics" view and so we see your post four times and have no idea which one to respond to.

 

Second, try something like this:

 

IF(COUNTAX(FILTER('Task Allocation'[Task status]='In Progress'),[Task ID]) = 0,"In progress", "Completed)

 

 

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

 thanks @Greg_Deckler for reply and i will not do it again.

Status = 
IF(
    ISEMPTY(
        CALCULATETABLE(
            'Task Allocation'
            ,'Task Allocation'[Task Status] = "In Progress"
        )
    )
    ,"Completed"
    ,"In Progress"
)

This assumes a relationship between 'Project Master' and 'Task Allocation'.

 

CALCULATETABLE() will respect the row context of [Project ID] from 'Project Master' and give us the matching rows from 'Task Allocation'. Additionally, we apply a filter to return only rows where 'TaskAllocation'[Task Status] = "In Progress". We test the resulting table with ISEMPTY() which tests what it says. If there are no rows, we know the project is complete. If there are rows with "In Progress", then the project is in progress.

RakeshP
Helper I
Helper I

SELECT PM.ProjectID, PM.projectName,
CASE WHEN T.ProjectID IS NULL THEN 'Completed' ELSE 'In progress' END as ProjectStatus
FROM Project_Master PM,
(SELECT distinct ProjectiD
from task_allocation
where Task_status = 'In progress') t
WHERE pm.ProjectID = t.ProjectiD(+)

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.