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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jenn3301
Frequent Visitor

Last non blank quarter

Hi all!

 

Where it displays FALSE, I am trying to obtain the last non blank value from the "Previous Quarter - Average Invoice Unit Price".

I can do this this when the quarter is -1 but if there is more than 1 quarter with no value it doesnt work.

Picture1.png

Average Invoice Unit Price =
CALCULATE(
AVERAGE('MaterialPurchasing'[Invc.price]),
FILTER('MaterialPurchasing',
'MaterialPurchasing'[Invc.price]<>0))


Previous Quarter Average Invoice Unit Price =
CALCULATE(
[Average Invoice Unit Price],
DATEADD ('Date_Table'[Date],
-1, QUARTER))


Price Every Quarter =
VAR _Current = [Average Invoice Unit Price]
VAR _Previous = [Previous Quarter Average Invoice Unit Price]

RETURN
IF(_Current <> BLANK() && _Previous = BLANK(), _Current,
IF(_Current <> BLANK() && _Previous <> BLANK(), _Current,
IF(_Current = BLANK() && _Previous <> BLANK(), _Previous,
"FALSE")))

2 REPLIES 2
sjoerdvn
Super User
Super User

You will need a column in your date dimension with sortable year & quarter values, like 20194,20201, 20202 etc.
But then this could work:

 

Previous Quarter Average Invoice Unit Price = 
VAR curqtr = MIN('Date_Table'[YearQuarter])
VAR prevqtrs = CALCULATETABLE(VALUES('Date_Table'[YearQuarter]),ALL('Date'), 'Date_Table'[YearQuarter]<curqtr)
RETURN IF(NOT(ISBLANK([Average Invoice Unit Price])),LASTNONBLANKVALUE(prevqtrs,[Average Invoice Unit Price]))

 

barritown
Super User
Super User

Hi @Jenn3301,

You could apply the logic from the example below to solve your problem. However in your case the code is supposed to be more complicated - should you provide a mock dataset, I can try to adapt this logic for your measures.

barritown_0-1695284859273.png

In plain text for convenience:

NewValue = 
IF ( NOT ISBLANK ( [Value] ), 
     [Value],
     VAR CurrentPeriod = [Period]
     VAR LastValuePeriod = MAXX ( FILTER ( Data, NOT ISBLANK ( [Value] ) && [Period] < CurrentPeriod ), [Period] )
     RETURN MINX ( FILTER ( Data, [Period] = LastValuePeriod ), [Value] )
)

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.