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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

A column based on the last value in a different column

Hello,

 

I'm not sure how to create a column that always takes data from a different column, but only from the last period and duplicates it for all previous periods.

What I mean is something like the screenshot, third column is the one I want to create based on column with values

 

 2019-02-08 12_49_50-Power BI Database 2018 - Excel.png

1 ACCEPTED SOLUTION

Hi @Anonymous

Create a column

Column = CALCULATE(MAX(Sheet1[period]),ALLEXCEPT(Sheet1,Sheet1[region]))

create a measure

Measure = CALCULATE(MAX(Sheet1[target]),FILTER(ALLEXCEPT(Sheet1,Sheet1[region]),[period]=[Column]))

7.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
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

5 REPLIES 5
Anonymous
Not applicable

@Anonymous

 

Hey!

 

I typically use LOOKUPVALUE for situations like this.

 

Here is a link to documentation on that that particular function:

 

https://docs.microsoft.com/en-us/dax/lookupvalue-function-dax

Anonymous
Not applicable

Thank you for your reply. I'm still struggling to make it work, it says that it doesn't support date type.

Also as I read the documentation I'm not sure if it woudn't leave other rows blank instead of duplicating the result (if it worked with date type)?

 

Should this give me the year end target column on the screen?

Year End Target = LOOKUPVALUE(Table[Target], Table[Period], "01.12.2018") 

 

 

2019-02-08 14_06_57-Schedule Wojciech Piaskowski - Excel.png

Hi @Anonymous

 

It is not quite clear whether you want a measure in a table visual or a calculated column in your table. 

 

A) For a measure (with Region, Period and Target in values of the table visual):

 

 

Measure Year End Target =
VAR _LatestPeriod =
    MAX ( Table1[Period] )
RETURN
    CALCULATE ( DISTINCT(Table1[Target]), Table1[Period] = _LatestPeriod )

 

B) For an additional calculated column in your table (assuming its columns are Region, Period and Target as you show):

 

 

Measure Year End Target =
VAR _LatestPeriod =
    CALCULATE ( MAX ( Table1[Period] ), ALLEXCEPT ( Table1, Table1[Region] ) )
RETURN
    CALCULATE (
        DISTINCT(Table1[Target]),
        Table1[Period] = _LatestPeriod,
        ALL ( Table1[Target] )
    )

 

 

Anonymous
Not applicable

Hey @AlB, thank you for helping. I think that a calculated column would be better here, but regardless of which one I try to execure, I can't use my column Target as first argument in Calculate function.

 


   CALCULATE (
        Table1[Target],
        Table1[Period] = _LatestPeriod,
        ALL ( Table1[Target] )
    )

 

What I have is a visual table, inside it there is Region, Actual, Target, Deviation, Percentage Deviation. Whole visual is filtered for just the current month. So there is only monthly data inside it.

 

Now I need a deviation from a year end target (so a deviation between eg. february actual and december target), but I don't know how to do this if visual is filtered for just the current month, thats why I wanted to duplicate a column with just values from the last period.

Hi @Anonymous

Create a column

Column = CALCULATE(MAX(Sheet1[period]),ALLEXCEPT(Sheet1,Sheet1[region]))

create a measure

Measure = CALCULATE(MAX(Sheet1[target]),FILTER(ALLEXCEPT(Sheet1,Sheet1[region]),[period]=[Column]))

7.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors