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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mvananaken
Helper II
Helper II

Calculated table with SUMX aggregation

Hello Folks,

 

I got a example table with (note: occurence multiple rows per employee per date is possible)

 

Date               Employee        hours

2016-01-01   Employee A       8

2016-01-01   Employee A       8

2016-01-01   Employee B       8

2016-01-01   Employee B       8

2016-01-01   Employee C       8

 

Now i want a  new calculated table with:

 

Date               Employee        hours

2016-01-01   Employee A       16

2016-01-01   Employee B       16

2016-01-01   Employee C       8

 

(background: in this table I want to made a custom column with a corrected hours of max 8 hours per date per employee), and the corrected hours are the base to make a calculed sum of (corrected) hours. 

 

How to achieve this?

 

Best regards,

 

Marco

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @mvananaken,

 

Based on my understanding, the "corrected hours of max 8 hours" means the max hour value is 8 even if one employee's working hours in one day is larger than 8 hours, right?

 

If so, you can add a calculated column in original table to generate the corrected hours. DAX formula can be:

Column = IF('SUMX'[Hours]>8,8,'SUMX'[Hours])

 

Then, new a calculate table to get the sum of hours per employee per date.

SUMX2 =
SUMMARIZE (
    'SUMX',
    'SUMX'[Date],
    'SUMX'[Employee],
    "Total", SUM ( 'SUMX'[Column] )
)

 

If you have any question, please feel free to ask.

 

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

5 REPLIES 5
BhaveshPatel
Community Champion
Community Champion

Hi Marco,

 

You can use GroupBy in the Query Editor to get the expected results.

GROUPBYGROUPBYEXPECTED RESULTSEXPECTED RESULTS

 

OR YOU CAN CREATE A CALCULATED COLUMN WITH THE BELOW DAX SYNTEX.

 

 

TOTAL= CALCULATE(SUM[Table[Hours]),

                          FILTER(Table,

                                      Table[Employee]=EARLIER(Tabel[Employee])

                                      )

                                    )

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Great solution! Thank you very much!

Hello @BhaveshPatel,

 

Thanks for help! I really appreciate it.

 

The first edit query method is not possible in my case, because I want to use a related custom column  in DAX to group by, who won't exist in edit query. But in other cases: this is the best solution i guess.

 

The second DAX option works, but I need specific a sum of hours per employee per date. How to achieve this? (new calculated table or an other possible way) 

 

 

Best regards,

 

Marco van Aken

 

 

Hi @mvananaken,

 

Based on my understanding, the "corrected hours of max 8 hours" means the max hour value is 8 even if one employee's working hours in one day is larger than 8 hours, right?

 

If so, you can add a calculated column in original table to generate the corrected hours. DAX formula can be:

Column = IF('SUMX'[Hours]>8,8,'SUMX'[Hours])

 

Then, new a calculate table to get the sum of hours per employee per date.

SUMX2 =
SUMMARIZE (
    'SUMX',
    'SUMX'[Date],
    'SUMX'[Employee],
    "Total", SUM ( 'SUMX'[Column] )
)

 

If you have any question, please feel free to ask.

 

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.

Thanks a lot @v-yulgu-msft!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.