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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PelaezLink
Helper I
Helper I

Error in <expression> part in LASTNONBLANK function.

Hello everyone.

So I have the following DAX expression for a measure:

 

Measure = LASTNONBLANK(FACTCooperativa[Year]; FACTCooperativa[Ratio9PACA])
 
Basically in FACTCooperativa table I have an ID column, a Year column (which ranges between 2016 an 2020) and then some columns that represent values of certain ratios for each year and each ID number. This table always has a filter on, making it only have the date for one ID number. In reality the table has hundread of rows, 5 for each ID number (year 2016-2020) but because of the filter the table is all the time only with 5 rows. The thing is I want the Measure to give me the last year in which the value of 'Ratio9PACA' is not blank, but I get an error alway in the second part (<expression>). I do not know what is causing it. Error says:
"A single value for column 'R9PACA' in table 'FACTCooperativa' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
I tried using the SELECTEDVALUE for the expression part but is not giving the correct results.
 
Thanks for all the help in advance.
 
1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

@PelaezLink 

 

Please have a look at the documentation first.

There are also examples of how to use this function -> LASTNONBLANK – DAX Guide

 

Assuming that certain conditions are met by your design, this might do the job:

[Measure] = 
LASTNONBLANK(
    FACTCooperativa[Year],
    // You need a context transition here.
    CALCULATE(
        SELECTEDVALUE( FACTCooperativa[Ratio9PACA] )
    )
)

 

 

View solution in original post

3 REPLIES 3
daXtreme
Solution Sage
Solution Sage

@PelaezLink 

 

Please have a look at the documentation first.

There are also examples of how to use this function -> LASTNONBLANK – DAX Guide

 

Assuming that certain conditions are met by your design, this might do the job:

[Measure] = 
LASTNONBLANK(
    FACTCooperativa[Year],
    // You need a context transition here.
    CALCULATE(
        SELECTEDVALUE( FACTCooperativa[Ratio9PACA] )
    )
)

 

 

Thank you very much that worked perfectly. I dont really understand why with CALCULATE does work but it does.

@PelaezLink 

 

Please learn about context transition. Then you'll understand. Start here: Understanding context transition in DAX - SQLBI

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.