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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Sum column values based on another column

Hi

 

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

[date][time][table][rows loaded]

 

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
sreenathv
Solution Sage
Solution Sage

 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]

 

View solution in original post

4 REPLIES 4
sreenathv
Solution Sage
Solution Sage

 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]

 

Anonymous
Not applicable

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)
PattemManohar
Community Champion
Community Champion

@Anonymous 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

 

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

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)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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