cancel
Showing results for
Did you mean:
Highlighted
adetogni Established Member

## Sum column values based on another column

Hi

I have a logging tool that reports me these column in the table "IMPORT"

So for example

01/10/2018 - 16:30 - table x - 100

01/10/2018 - 16:30 - table y - 250

So when I want to have the amount of rows loaded on a certain date, it's fairly easy with a visual.

I have then this visual

table   |  Last Import

table x |   100

table y |   250

TOTAL  |  350

Works fine

However, sometimes the importin runs twice so I have things like

01/10/2018 - 16:30 - table x - 100

01/10/2018 - 16:40 - table x - 120

01/10/2018 - 16:30 - table y - 250

01/10/2018 - 16:40 - table y - 257

In cases like this I would like to have, in the report only the rows where the date is the max, given a certain date.

So I wrote this DAX:

Last Import = SUMx(filter('Import';max('Import'[time]));'Import'[rows])

My concept is: filter my table import on the max value of import[time] and sum the [rows].

Now this works EXCEPT for the total, so I have something like

table   |  Last Import

table x |   120

table y |   257

TOTAL  |  727

It's like the measure is not filtered on the total row

What am I doing wrong? Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
sreenathv Member

## Re: Sum column values based on another column

Hi,

Try using this formula to create a calculated column and use this new calculated column for your purpose.

`LastLoadedRowCount = IF('Import'[Time]=MAXX(FILTER(ALL('Import'),EARLIER('Import'[Table])='Import'[Table] && EARLIER('Import'[Date])='Import'[Date]),'Import'[Time]),1,0) *'Import'[RowsLoaded]`

4 REPLIES 4 Super User

## Re: Sum column values based on another column

@adetogni Could you please try with a simple "Table" visual, having TableName and Rows field as values... It should work fine, as you have all fields in single table that are required, also you can have a date slicer to select a particular date as well.

Not sure, why you are using DAX expressions for this Did I answer your question? Mark my post as a solution !

Proud to be a Datanaut !

sreenathv Member

## Re: Sum column values based on another column

Hi,

Try using this formula to create a calculated column and use this new calculated column for your purpose.

`LastLoadedRowCount = IF('Import'[Time]=MAXX(FILTER(ALL('Import'),EARLIER('Import'[Table])='Import'[Table] && EARLIER('Import'[Date])='Import'[Date]),'Import'[Time]),1,0) *'Import'[RowsLoaded]`

adetogni Established Member

## Re: Sum column values based on another column

Hi and thanks

Because I don't want 727. The table x, for a certain date, has 2 rows and if I do it that way it will report the sum of the two rows. Instead I want only the row where the time is max (i.e. The latest log line)
adetogni Established Member

## Re: Sum column values based on another column

Hi
Indeed it does work. However having a calculated column is memory intensive and I wanted to have it as a measure (also because I'm learning dax and trying to make it work)