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
Anonymous
Not applicable

New column returns value by looking up corresponding value from a date column + X Months

I have one table and I want to create a "New Value Column".

Each Unique Name has an "Original Month".

I want to add 36 months to the Original Month value, then look up the corresponding date from the "Lookup Month' column, then lookup the value from the "Original Value" column, and set that value as the new value  for "New Value Column" every time you see that Unique Name. 

If there is no "Original Month + 36 months", then set the "New Value Column" as null for that Unique Name.

 

Thank you for the help.

NameLookup MonthOriginal MonthOriginal Value New Value Column
John6/1/201711/20/2015118
John7/1/201711/20/2015218
John8/1/201711/20/2015318
John9/1/201711/20/2015418
John10/1/201711/20/2015518
John11/1/201711/20/2015618
John12/1/201711/20/2015718
John1/1/201811/20/2015818
John2/1/201811/20/2015918
John3/1/201811/20/20151018
John4/1/201811/20/20151118
John5/1/201811/20/20151218
John6/1/201811/20/20151318
John7/1/201811/20/20151418
John8/1/201811/20/20151518
John9/1/201811/20/20151618
John10/1/201811/20/20151718
John11/1/201811/20/20151818
Betty3/1/201811/28/20171null
Betty4/1/201811/28/20172null
Betty5/1/201811/28/20173null
Betty6/1/201811/28/20174null
Betty7/1/201811/28/20175null
Betty8/1/201811/28/20176null
Betty9/1/201811/28/20177null
Betty10/1/201811/28/20178null
Betty11/1/201811/28/20179null
Betty12/1/201811/28/201710null
Betty1/1/201911/28/201711null
Betty2/1/201911/28/201712null
Betty3/1/201911/28/201713null
Betty4/1/201911/28/201714null
Betty5/1/201911/28/201715null
Betty6/1/201911/28/201716null
Betty7/1/201911/28/201717null
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try below steps:

1. create a measure with below dax formula

Measure =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_om =
    SELECTEDVALUE ( 'Table'[Original Month] )
VAR cur_om_year =
    YEAR ( cur_om )
VAR cur_om_month =
    MONTH ( cur_om )
VAR tmp1 =
    FILTER ( ALL ( 'Table' ), 'Table'[Name] = cur_name )
VAR _val =
    CALCULATE (
        MAX ( [Original Value ] ),
        FILTER (
            tmp1,
            YEAR ( [Lookup Month] ) = cur_om_year + 3
                && MONTH ( [Lookup Month] ) = cur_om_month
        )
    )
RETURN
    IF ( ISBLANK ( _val ), "null", _val )

2. add a table visual with fields and measure

vbinbinyumsft_0-1669085629070.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try below steps:

1. create a measure with below dax formula

Measure =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_om =
    SELECTEDVALUE ( 'Table'[Original Month] )
VAR cur_om_year =
    YEAR ( cur_om )
VAR cur_om_month =
    MONTH ( cur_om )
VAR tmp1 =
    FILTER ( ALL ( 'Table' ), 'Table'[Name] = cur_name )
VAR _val =
    CALCULATE (
        MAX ( [Original Value ] ),
        FILTER (
            tmp1,
            YEAR ( [Lookup Month] ) = cur_om_year + 3
                && MONTH ( [Lookup Month] ) = cur_om_month
        )
    )
RETURN
    IF ( ISBLANK ( _val ), "null", _val )

2. add a table visual with fields and measure

vbinbinyumsft_0-1669085629070.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.