Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have a table with multiple attribute/category columns (call them A1, A2, ...), a date column and a value column.
I've been trying for too long to get a measure that gives me the value for the previously available date, given that all attribute are the same.
Example:
date A1 A2 .... value new_measure
06/30/2023 a c 1 BLANK
06/30/2023 b d 2 BLANK
07/03/2023 a c 3 1
07/04/2023 a c 4 3
07/03/2023 a d 5 BLANK
07/04/2023 a d 6 5
How can I do it?
Nothing of the above worked. I ended up using an actually useful tool (a Python script) to do that before feeding it into Power BI. I guess it's my fault for thinking a Microsoft product would work.
HI @gchn,
Here is the dax measure formula and sample file about get the previous value based on use current date and multiple attribute field values:
formula =
VAR currDate =
MAX ( 'Table'[date] )
VAR prevDate =
CALCULATE (
MAX ( 'Table'[date] ),
FILTER ( ALLSELECTED ( 'Table' ), [date] < currDate ),
VALUES ( 'Table'[A1] ),
VALUES ( 'Table'[A2] )
)
RETURN
IF (
prevDate <> BLANK (),
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( ALLSELECTED ( 'Table' ), [date] = prevDate ),
VALUES ( 'Table'[A1] ),
VALUES ( 'Table'[A2] )
)
)
Regards,
Xiaoxin Sheng
Hi @gchn ,
Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.
If these also don't help, please share more detailed information and description to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Hi @gchn
Try using:-
new_measure =
VAR CurrentDate = MAX('YourTable'[date])
VAR PrevDate =
CALCULATE(
MAX('YourTable'[date]),
FILTER(
ALL('YourTable'),
'YourTable'[date] < CurrentDate &&
'YourTable'[A1] = EARLIER('YourTable'[A1]) &&
'YourTable'[A2] = EARLIER('YourTable'[A2]) &&
...
)
)
RETURN
IF(ISBLANK(PrevDate), BLANK(),
CALCULATE(
MAX('YourTable'[value]),
FILTER(
ALL('YourTable'),
'YourTable'[date] = PrevDate &&
'YourTable'[A1] = EARLIER('YourTable'[A1]) &&
'YourTable'[A2] = EARLIER('YourTable'[A2]) &&
...
)
)
)
Hope this will help.
Just the EARLIER function doesnt' work, can you be more specific?
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.