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

Create multiple rows against unique Tasks using DAX

Hi,

I have a table with different tasks as follows , I want to create 3 records for each task to track the efforts against 3 values(Estimated, Spent & Remaining) as follows. Any help to dynamically get the data using DAX in desired format is much appreaciated.

 

Original Table

Task IDTitleTask StatusAssignedToEstimatedHoursCompletedHours
1Task AOpenTom8

0

 

2Task BIn ProressDavid2410
3Task COpenRaj300
4Task DClosedTom1010
5Task EOpenDavid120

 

Status

 

EffortStatus
Assgined
Spent
Remaining

 

Need data in below format,

   

Task IDTitleTask StatusAssignedToEffortStatusHours
1Task AOpenTomAssgined8
1Task AOpenTomSpent0
1Task AOpenTomRemaining8
2Task BIn ProressDavidAssgined24
2Task BIn ProressDavidSpent10
2Task BIn ProressDavidRemaining14

 

Probably I have to create 3 rows with new column as " EffortStatus" first, and then loop and based on the "EffortStatus" value, I have to calculate the hours.

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to creat a table like below.

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1718039461984.png

 

 

expected result table = 
VAR _t =
    SUMMARIZE (
        'Original Table',
        'Original Table'[Task ID],
        'Original Table'[Title],
        'Original Table'[Task Status],
        'Original Table'[AssignedTo]
    )
VAR _effortstatus = 'Status'
VAR _result =
    GENERATE ( _t, _effortstatus )
RETURN
    ADDCOLUMNS (
        _result,
        "Hours",
            SWITCH (
                TRUE (),
                'Status'[EffortStatus] = "Assgined",
                    SUMX (
                        FILTER (
                            'Original Table',
                            'Original Table'[Task ID] = EARLIER ( 'Original Table'[Task ID] )
                        ),
                        'Original Table'[EstimatedHours]
                    ),
                'Status'[EffortStatus] = "Spent",
                    SUMX (
                        FILTER (
                            'Original Table',
                            'Original Table'[Task ID] = EARLIER ( 'Original Table'[Task ID] )
                        ),
                        'Original Table'[CompletedHours]
                    ),
                SUMX (
                    FILTER (
                        'Original Table',
                        'Original Table'[Task ID] = EARLIER ( 'Original Table'[Task ID] )
                    ),
                    'Original Table'[EstimatedHours] - 'Original Table'[CompletedHours]
                )
            )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
snehasissamal
Frequent Visitor

Hi @Jihwan_Kim ,

 

Thank you so much it worked as expected &  have marked as accepted answer so that it may help opthers.

 

I was looking at the output, for different Tasks, Status column values are in dfferent order. For Example. for Task A, Status values are (Spent, Assigned, Remaining) while for TaskB, its (Assigned, Spent, Remaining) as in the picture. 

 

Can we sort it or keep it in same order?

EffortStatusOrder.png

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to creat a table like below.

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1718039461984.png

 

 

expected result table = 
VAR _t =
    SUMMARIZE (
        'Original Table',
        'Original Table'[Task ID],
        'Original Table'[Title],
        'Original Table'[Task Status],
        'Original Table'[AssignedTo]
    )
VAR _effortstatus = 'Status'
VAR _result =
    GENERATE ( _t, _effortstatus )
RETURN
    ADDCOLUMNS (
        _result,
        "Hours",
            SWITCH (
                TRUE (),
                'Status'[EffortStatus] = "Assgined",
                    SUMX (
                        FILTER (
                            'Original Table',
                            'Original Table'[Task ID] = EARLIER ( 'Original Table'[Task ID] )
                        ),
                        'Original Table'[EstimatedHours]
                    ),
                'Status'[EffortStatus] = "Spent",
                    SUMX (
                        FILTER (
                            'Original Table',
                            'Original Table'[Task ID] = EARLIER ( 'Original Table'[Task ID] )
                        ),
                        'Original Table'[CompletedHours]
                    ),
                SUMX (
                    FILTER (
                        'Original Table',
                        'Original Table'[Task ID] = EARLIER ( 'Original Table'[Task ID] )
                    ),
                    'Original Table'[EstimatedHours] - 'Original Table'[CompletedHours]
                )
            )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.