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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

undefined

I have a dimention table as below. product code is type text, monthyear is type date, MRP is type decimal, flag is type text.

 

ProductCodeMonthYearMRPFlag
123jan,202210NO
123feb,202210NO
123March,202210NO
123April, 202215YES
121jan,20221212
121march,202215yes

 

In above table i need to add a calculated column as below.

ProductCodeMonthYearMRPFlagEnd date
123jan,202210NO30/03/2022
123feb,202210NO30/03/2022
123March,202210NO30/03/2022
123April, 202215YES 
121jan,2022121228/02/2022
121march,202215yes 

 

I need to add recent date previous date as end date, when MRP got change, in to new calculated column.
It is very helpfull if some one give reply to me as soon as possible. Thanks in Advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

You can try the following code:

End Date = IF([Flag]="Yes",BLANK(),MAXX(FILTER('Table','Table'[ProductCode]=EARLIER('Table'[ProductCode])&&[Flag]="Yes"),[MonthYear])-1)

vxinruzhumsft_0-1673322993459.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous 

You can try the following code:

End Date = IF([Flag]="Yes",BLANK(),MAXX(FILTER('Table','Table'[ProductCode]=EARLIER('Table'[ProductCode])&&[Flag]="Yes"),[MonthYear])-1)

vxinruzhumsft_0-1673322993459.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

FreemanZ
Community Champion
Community Champion

hi @Anonymous 

do you have other date column in other format beside this one - "jan, 2022"? 

Anonymous
Not applicable

NO, I have onle one date column in this table.

hi @Anonymous 

Just realized "jan, 2022" is converted to 1/1/2022 by Power BI automatically. If it is also the case for you, try to add a column like this:

EndDate = 
VAR _mrp = [MRP]
VAR _product = [ProductCode]
VAR _table = FILTER(TableName, TableName[ProductCode] = _product)
VAR _maxmy = MAXX( FILTER(_table, TableName[MRP] = _mrp), TableName[MonthYear])
VAR _value = 
MINX(
    FILTER(_table, TableName[MRP]<>_mrp),
    TableName[MonthYear]
)-1
RETURN
IF([Flag]<>"YES", _value)

i tried and it worked like this:

FreemanZ_0-1673244639518.png

 

p.s. please consider @ someone, if you still seek further suggestions. 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.