Forum Discussion

jmdaily83's avatar
jmdaily83
Icon for Helper II rankHelper II
2 years ago

Assign specific value to repeating blanks in a column based on the order they're in

Hello - I have a table similiar to the sample table below.  The subtotal1/subtotal2/total does not pull in with my query due to the way the files are structured and pulled in.  The blanks will always be in the same order for each project but not necessarily in the same amount of rows from the previous section. (ie subtotal 1 could have 15 rows above it in Project A and 25 above it in Project B). I need to create a new column that assigns subtotal1/subtotal2/total based on these blanks.  

 

I have tried this custom column but it does not work, it just spins & spins and never even shows an error.  

= Table.AddColumn(#"Added Index", "Custom", each let

__Project = [Project Number],

__Index = [Index],

__Table = Table.SelectRows( #"Added Custom", each ([Project Number] = __Project and [Index] > __Index ) )

in

  Table.RowCount(__Table) + 1)

 

 

 

ProjectkWh CategoryItem CategoryItem Type$New KWH Category
AEngineeringBESS EngineeringElectrical100Engineering
AMBOM MaterialBESS MaterialBESS Material200MBOM Material
ABOP MaterialElectrical BOP MaterialAux Material300BOP Material
AEPC BOPBOP CivilCivil400EPC BOP
ASubstationSubstationSubstation Engineering500Substation
ATransmission LineTransmission LineTransmission Line600Transmission Line
ASubstationSubstationSubstation700Substation
AFreightFreightMBOM+BOP Freight800Freight
AEPC BOPOtherInsurance900EPC BOP
AMBOM MaterialBESS MaterialWarranties1000MBOM Material
AProject ServicesSite LabourSite Labour1100Project Services
A   6600Subtotal 1
AEPC BOPOtherPermitting1300EPC BOP
AContingencySourcing ContingencySourcing Contingency1400Contingency
A   9300Subtotal 2
ASales TaxSales TaxSales Tax1600Sales Tax
ABonding BondingBonding1700Bonding 
A   12600Total
BEngineeringBESS EngineeringElectrical100Engineering
BMBOM MaterialBESS MaterialBESS Material200MBOM Material
BBOP MaterialElectrical BOP MaterialAux Material300BOP Material
BEPC BOPBOP ElectricalBESS  Site Commissioning400EPC BOP
BSubstationSubstationSubstation Engineering500Substation
BTransmission LineTransmission LineTransmission Line600Transmission Line
BSubstationSubstationSubstation Commissioning700Substation
BFreightFreightMBOM+BOP Freight800Freight
BEPC BOPOtherInsurance900EPC BOP
BMBOM MaterialBESS MaterialWarranties1000MBOM Material
BProject ServicesSite LabourSite Labour1100Project Services
B   6600Subtotal 1
BEPC BOPOtherPermitting1200EPC BOP
BContingencySourcing ContingencySourcing Contingency1300Contingency
BContingencyRisk ContingencyRisk Contingency1400Contingency
B   10500Subtotal 2
BSales TaxSales TaxSales Tax1500Sales Tax
BBonding BondingBonding1600Bonding 
B   13600Total

4 Replies

  • Hi,

    Not sure of what you want but you should never create subtoal/total rows in any table.  These summarisation rows get created automatically when you create Table/matrix visuals.

    • jmdaily83's avatar
      jmdaily83
      Icon for Helper II rankHelper II

      Ashish_Mathur Thank you for your response. That's how I would typically do it, but in this particular visual the subtotals need to add together and this does not happen naturally in a matrix. So I need Subtotal 1, Subtotal 2 = subtotal 1 + subtotal 2, total = item A + item B + Subtotal 1 + Subtotal 2

       

      Current matrix functionality

       

       

      What I need - (notice no subtotal 3) and subtotals are added together

       

       

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jmdaily83 ,

     

    You'd better add a level2 column in you table to dispaly your second level. And it's best to determine this level and import it together before importing, which is more convenient.

    Column = CALCULATE(SUM('Table'[$]),FILTER('Table',[Project]=EARLIER('Table'[Project])&&[Level2]<=EARLIER('Table'[Level2])))

    Best Regards,

    Stephen Tao

     

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

     

  • The end user ended up adjusting the way things were labeled on their end so I no longer needed to do anything custom on my end. 

    thank you all for your help