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
TheQ
Frequent Visitor

Retrieve Last Date a Value Changed by Group

Hi everyone,

 

I've been troubleshooting this issue for a couple hours now to no avail. Let's say I have the following dataset:

GroupDateSetting
A1/30/235.3
A1/15/235.3
A1/5/234.7
B1/30/233.2
B1/29/232.7
B1/7/232.4
C1/28/236.1
C1/17/236.1
C1/1/235.2

I want to know the date of the most recent value change in this form:

GroupMost Recent SettingDate of Last Change
A5.31/15/23
B3.21/30/23
C6.11/17/23

 

I have tried a few variations of this as a Calculated Column:

 

 

 

Date of Last Change =
VAR _Setting = SUM( Table[Setting] )
VAR _Date = Table[Date]
RETURN
CALCULATE(
     MAX( Table[Date] ),
     ALLEXCEPT( Table, Table[Group] ),
     Table[Date] < _Date,
     SUM( Table[Setting] ) <> _Setting
)

 

 

 

This usually gives me the "The true/false expression does not specify a column" error. I was able to get past this by replacing the commas with &&, but end up with blanks for the whole column.

Thanks in advance for the help!
Q

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @TheQ 

try like:

NewColumn =
VAR _group = [Group]
VAR _grouptable = 
FILTER(
     TableName, 
     TableName[Group] = _group
)
VAR _lastdate =
MAXX(
    _grouptable,
   TableName[Date]  
)
VAR _lastsetting =
MAXX(
    FILTER(
         _grouptable,
         TableName[Date]=_lastdate
    ),
   TableName[Setting]  
)
RETURN
MINX(
    FILTER(
         _grouptable,
         TableName[Setting] = _lastsetting
    ),
    TableName[Date]
)

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @TheQ 

try like:

NewColumn =
VAR _group = [Group]
VAR _grouptable = 
FILTER(
     TableName, 
     TableName[Group] = _group
)
VAR _lastdate =
MAXX(
    _grouptable,
   TableName[Date]  
)
VAR _lastsetting =
MAXX(
    FILTER(
         _grouptable,
         TableName[Date]=_lastdate
    ),
   TableName[Setting]  
)
RETURN
MINX(
    FILTER(
         _grouptable,
         TableName[Setting] = _lastsetting
    ),
    TableName[Date]
)
TheQ
Frequent Visitor

Thanks @FreemanZ ! That amazingly worked. Do you have any idea why this worked and my original method didn't? I've used my original method successfully on a similar case but where the "Setting" wasn't a number, but a "Passed"/"Failed" column.

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.

Top Solution Authors