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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.