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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Grouped sum based on each phase field - Direct Query

Hello! I've been stuck on this problem for a while now so thought I would reach out. I am using a Direct Query method so I am not able to use grouping in a power query to accomplish this.

 

Each phase would have one row with the columns summarized for cost types 1,2,8. 

Below is a sample data set and then the totals I would expect to see for the Phase. Any help is appreciated, thank you! 

 

JobPhaseCostType  SpentCmdtCost  NonCmdtCost  CurrEstCost  BuyOutTotalCmtdCostCurrBuyoutCost
211037  01-040 .   .  1             0107239.92118734-28020.360146754.36
211037 01-040 .   .2039508.6300039508.63
21103701-040 .   .808578.530008578.53
21103701-042 .   .1023979.6831339-529.52031868.52
21103701-042 .   .207900.410007900.41
21103701-042 .   .801918.380001918.38
21103701-043 .   .1041254.433443-22031.27055474.27
21103701-043 .   .2012992.7600012992.76
21103701-043 .   .803300.120003300.12
21103701-044 .   .109295.998049-5423.23013472.23
21103701-044 .   .203266.70003266.7
21103701-044 .   .80743.54000743.54
21103701-049 .   .102318.040-3260.6903260.69
21103701-049 .   .20757.12000757.12
21103701-049 .   .80185.53000185.53

 

Phase 01-040 Totals: 

  • SpentCmdtCost = 0
  • NonCmdtCost = 152,469.51
  • CurrEstCost = 118,734.00
  • BuyOut = 28,020.36

Phase 01-042 Totals: 

  • SpentCmdtCost = 0
  • NonCmdtCost = 33,353.77
  • CurrEstCost = 31,399.00
  • BuyOut = -529.52
4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous 

Create four measures to sum these fields .

SpentCmdtCost Total = CALCULATE(SUM('Table'[SpentCmdtCost]),ALLEXCEPT('Table','Table'[Phase]))
NonCmdtCost Total = CALCULATE(SUM('Table'[NonCmdtCost]),ALLEXCEPT('Table','Table'[Phase]))
CurrEstCost Total = CALCULATE(SUM('Table'[CurrEstCost]),ALLEXCEPT('Table','Table'[Phase]))
BuyOut Total = CALCULATE(SUM('Table'[BuyOut]),ALLEXCEPT('Table','Table'[Phase]))

Then add field [Phase] in a slicer , when you choose different Phase, you will get different totals .

Ailsamsft_0-1645767587563.pngAilsamsft_1-1645767587565.png

I have attached my pbix file , you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you so much for this! I can't use a slicer to separate the phases individually, I need one row per phase that adds up the cost types 1,2 and 8 in one single table. Here is another example: 

 

JobPhaseCostType  SpentCmdtCost  NonCmdtCost  CurrEstCost  BuyOutTotalCmtdCostCurrBuyoutCost
211037  01-040 .   .  1             0107239.92118734-28020.360146754.36
211037 01-040 .   .2039508.6300039508.63
21103701-040 .   .808578.530008578.53
21103701-042 .   .1023979.6831339-529.52031868.52
21103701-042 .   .207900.410007900.41
21103701-042 .   .801918.380001918.38
21103701-043 .   .1041254.433443-22031.27055474.27
21103701-043 .   .2012992.7600012992.76
21103701-043 .   .803300.120003300.12
21103701-044 .   .109295.998049-5423.23013472.23
21103701-044 .   .203266.70003266.7
21103701-044 .   .80743.54000743.54
21103701-049 .   .102318.040-3260.6903260.69
21103701-049 .   .20757.12000757.12
21103701-049 .   .80185.53000185.53

 

 

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Avoid posting screenshots of your source data if possible.

Anonymous
Not applicable

Here is the data:

 

JobPhaseCostTypeSpentCmdtCostNonCmdtCostCurrEstCostBuyOutTotalCmtdCostCurrBuyoutCost
211037 01-040 .   .  10107239.9118734-28020.40146754.4
211037 01-040 .   .  2039508.6300039508.63
211037 01-040 .   .  808578.530008578.53
211037 01-042 .   .  1023979.6831339-529.52031868.52
211037 01-042 .   .  207900.410007900.41
211037 01-042 .   .  801918.380001918.38

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors