cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create new row based on previous row and sum the values

Hi Everyone,

 

I'm striving to create report based on the below input:

 

 Input.JPG

 

Criteria:

For every Emp Id in table should create one new row (refering above row details like proj Code, Hrs Leaves and Actual Hrs) & it should sum Unbilled(if available) + Leaves columns of respective Emp in Tot Hrs column. At same time, status column should display with 0.

 

Below is out:

 

Output.JPG

 

Could you please help me to acheive this.

 

Regards,

Arjun

 

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft v-yulgu-msft
Microsoft

Re: Create new row based on previous row and sum the values

Hi @Anonymous,

 

Please new calculated tables with below DAX formulas: (suppose source table is called 'Test3')

Test3_1 =
SUMMARIZE (
    SELECTCOLUMNS (
        Test3,
        "Emp ID", Test3[Emp ID],
        "Proj Code", Test3[Proj Code],
        "Hrs", Test3[Hrs],
        "Leaves", Test3[Leaves],
        "Actual Hrs", Test3[Actual Hrs],
        "Tot Hrs", 0,
        "Unbilled", 0,
        "Status", 0
    ),
    [Emp ID],
    [Proj Code],
    "Hrs", AVERAGE ( Test3[Hrs] ),
    "Leaves", AVERAGE ( Test3[Leaves] ),
    "Actual Hrs", AVERAGE ( Test3[Actual Hrs] ),
    "Tot Hrs", 0,
    "Unbilled", 0,
    "Status", 0
)

Test3_2 =
UNION ( Test3, Test3_1 )

Test3_3 =
ADDCOLUMNS (
    SUMMARIZE (
        Test3_2,
        Test3_2[Emp ID],
        Test3_2[Proj Code],
        Test3_2[Status],
        "Hrs", AVERAGE ( Test3_2[Hrs] ),
        "Leaves", AVERAGE ( Test3_2[Leaves] ),
        "Actual Hrs", AVERAGE ( Test3_2[Actual Hrs] ),
        "Tot Hrs", SUM ( Test3_2[Tot Hrs] ),
        "Unbilled", SUM ( Test3_2[Unbilled] )
    ),
    "Final Tot Hours", IF ( Test3_2[Status] = 0, [Leaves] + [Unbilled], [Tot Hrs] )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Microsoft v-yulgu-msft
Microsoft

Re: Create new row based on previous row and sum the values

Hi @Anonymous,

 

Please new calculated tables with below DAX formulas: (suppose source table is called 'Test3')

Test3_1 =
SUMMARIZE (
    SELECTCOLUMNS (
        Test3,
        "Emp ID", Test3[Emp ID],
        "Proj Code", Test3[Proj Code],
        "Hrs", Test3[Hrs],
        "Leaves", Test3[Leaves],
        "Actual Hrs", Test3[Actual Hrs],
        "Tot Hrs", 0,
        "Unbilled", 0,
        "Status", 0
    ),
    [Emp ID],
    [Proj Code],
    "Hrs", AVERAGE ( Test3[Hrs] ),
    "Leaves", AVERAGE ( Test3[Leaves] ),
    "Actual Hrs", AVERAGE ( Test3[Actual Hrs] ),
    "Tot Hrs", 0,
    "Unbilled", 0,
    "Status", 0
)

Test3_2 =
UNION ( Test3, Test3_1 )

Test3_3 =
ADDCOLUMNS (
    SUMMARIZE (
        Test3_2,
        Test3_2[Emp ID],
        Test3_2[Proj Code],
        Test3_2[Status],
        "Hrs", AVERAGE ( Test3_2[Hrs] ),
        "Leaves", AVERAGE ( Test3_2[Leaves] ),
        "Actual Hrs", AVERAGE ( Test3_2[Actual Hrs] ),
        "Tot Hrs", SUM ( Test3_2[Tot Hrs] ),
        "Unbilled", SUM ( Test3_2[Unbilled] )
    ),
    "Final Tot Hours", IF ( Test3_2[Status] = 0, [Leaves] + [Unbilled], [Tot Hrs] )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Create new row based on previous row and sum the values

Thank you @v-yulgu-msft, for the solution.

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors