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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
KasperBI
Frequent Visitor

Checking for max value in summarized table DAX help

Hi everyone. I have data that looks like this:

 

TestCaseIDConfigurationRunDate
1108-04-2021 11:10:10
1108-04-2021 12:10:10
1208-04-2021 13:10:10
2108-04-2021 08:08:08
2208-04-2021 09:09:09
2208-04-2021 10:10:10
3108-04-2021 09:09:09
3108-04-2021 11:11:11
3208-04-2021 10:10:10

 

I have a table in my PBI report where the user can select test cases, and whatever configurations they want through slicers. I want the table to only display the latest test run within the configuration. 

 

So I ideally would create a calculated column that checks whether the current test/configuration is the last one for the configuration. The data output should look something like this:

 

TestCaseIDConfigurationRunDate FilterCheck
1108-04-2021 11:10:10Remove
1108-04-2021 12:10:10Keep
1208-04-2021 13:10:10Keep
2108-04-2021 08:08:08Keep
2208-04-2021 09:09:09Remove
2208-04-2021 10:10:10Keep
3108-04-2021 09:09:09Remove
3108-04-2021 11:11:11Keep
3208-04-2021 10:10:10Keep

 

This is the code I have so far:

LatestTest =
VAR MaxDateForCombo =
//returns a table with a combined column from test ID and Config name and the maximum (latest) test result.

SUMMARIZE (
ADDCOLUMNS (
'Test Results',
"TestIDConfig", CONCATENATE ( 'Test Results'[TestcaseId], 'Test Results'[Configuration] ),
"RunDate2", MAX ( 'Test Results'[RunDate] )
),
[TestIDConfig],
"MaxRunDate", MAX ( 'Test Results'[RunDate] )
)

//the current row context date
Var Currentdate = 'Test Results'[RunDate]

// If the current date is smaller than the maximum date for the selected combinations of runID and config then filter it out.
Var FilterCheck = IF(Currentdate<


,"Filter out","Keep in")
RETURN
FilterCheck


I am having problems with the filtercheck part. I thought about using lookupvalue on the summarized table to see if rundate2 was bigger than rundate, but I can't figure it out. can someone help me out to get to my desired result? 🙂
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @KasperBI 

 

Please correct me if I wrongly understood your question.

 

Please check the below Calculated Column and the link down below, which is the sample pbix file.

 

Latest Test Column =
VAR lastnonblankcheck =
CALCULATE (
LASTNONBLANK ( 'Test Results'[RunDate], MAX ( 'Test Results'[Configuration] ) ),
ALLEXCEPT (
'Test Results',
'Test Results'[TestCaseID],
'Test Results'[Configuration]
)
)
RETURN
IF ( 'Test Results'[RunDate] = lastnonblankcheck, "Keep", "Remove" )

 

https://www.dropbox.com/s/xxpqyuj3xk6l2or/KasperBI.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @KasperBI 

 

Please correct me if I wrongly understood your question.

 

Please check the below Calculated Column and the link down below, which is the sample pbix file.

 

Latest Test Column =
VAR lastnonblankcheck =
CALCULATE (
LASTNONBLANK ( 'Test Results'[RunDate], MAX ( 'Test Results'[Configuration] ) ),
ALLEXCEPT (
'Test Results',
'Test Results'[TestCaseID],
'Test Results'[Configuration]
)
)
RETURN
IF ( 'Test Results'[RunDate] = lastnonblankcheck, "Keep", "Remove" )

 

https://www.dropbox.com/s/xxpqyuj3xk6l2or/KasperBI.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you so much, that does seem to work. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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