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
Anonymous
Not applicable

Sum Column exclude Rows

example data:

 

LocationEnergyConsumedStartTimeMeter
road25/29/2018 13:000
dock125/29/2018 13:000
bridge25/29/2018 13:000
Master Meter155/29/2018 13:001
road35/29/2018 14:000
dock45/29/2018 14:000
bridge65/29/2018 14:000
Master Meter145/29/2018 14:001
road15/29/2018 15:000
dock35/29/2018 15:000
bridge55/29/2018 15:000
Master Meter105/29/2018 15:001

 

I would like to sum EnergyConsumed like so,

 

SUMMARIZECOLUMNS(
                     HourlyEnergyData[StartTime],
                    "Total", SUM(HourlyEnergyData[EnergyConsumed]

)

 

that creates a new table with it that looks like this,

 

TotalDate
145/29/2018 13:00
135/29/2018 14:00
95/29/2018 15:00

 

but exclude "Master Meter" from the summarized sum, total.

1 ACCEPTED SOLUTION

Please try the following calculated table.  I have attached a PBIX file with the code inside 🙂

 

Table = 
VAR BaseTable = SUMMARIZECOLUMNS(
                     HourlyEnergyData[StartTime],
                    FILTER('HourlyEnergyData','HourlyEnergyData'[Meter]=0) ,
                    "Total", SUM(HourlyEnergyData[EnergyConsumed]) 
                    )
RETURN  
    ADDCOLUMNS( 
        BaseTable,
        "Meter",MINX(
                    FILTER(
                        'HourlyEnergyData',
                        'HourlyEnergyData'[Meter]=1 && 
                        'HourlyEnergyData'[StartTime] = EARLIER('HourlyEnergyData'[StartTime])
                        ),
                        'HourlyEnergyData'[EnergyConsumed]) 
                  )

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @Anonymous

 

The SUMMARIZECOLUMNS function accepts a filter parameter as an argument so perhaps try this

 

Table = SUMMARIZECOLUMNS(
                     HourlyEnergyData[StartTime],
                    FILTER('HourlyEnergyData','HourlyEnergyData'[Meter]=0) ,
                    "Total", SUM(HourlyEnergyData[EnergyConsumed]) 
                    )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Yes that worked to how it was specified.

 

However, can you modify it to also include a column "Meter Value"? the  FILTER('HourlyEnergyData','HourlyEnergyData'[Meter]=0) , restricts me from adding "Meter Value" in as another column.  

 

What do you want to put in the 'Meter' column?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

The value of master meter,

 

ie. column of summed locations and column of master meter.

 

Thank you so much!

So based on the table you provided in the sample data.  What would the expected value be?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

TotalMaster MeterDate
14155/29/2018 13:00
13145/29/2018 14:00
9105/29/2018 15:00

Please try the following calculated table.  I have attached a PBIX file with the code inside 🙂

 

Table = 
VAR BaseTable = SUMMARIZECOLUMNS(
                     HourlyEnergyData[StartTime],
                    FILTER('HourlyEnergyData','HourlyEnergyData'[Meter]=0) ,
                    "Total", SUM(HourlyEnergyData[EnergyConsumed]) 
                    )
RETURN  
    ADDCOLUMNS( 
        BaseTable,
        "Meter",MINX(
                    FILTER(
                        'HourlyEnergyData',
                        'HourlyEnergyData'[Meter]=1 && 
                        'HourlyEnergyData'[StartTime] = EARLIER('HourlyEnergyData'[StartTime])
                        ),
                        'HourlyEnergyData'[EnergyConsumed]) 
                  )

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.