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
Ondra
Frequent Visitor

Difference between FIRSDATE and FIRSTNONBLANK while getting next row value

Hello!

 

I have a formula for a calculated column, which shows date of following row, like this:

 

NextTariffDate =
IF(
crm_flat_fees[dateuntil] <> BLANK() && RELATED(crm_services[servicetype]) = 1,
CALCULATE (
  FIRSTDATE( crm_flat_fees[datefrom] ),
  FILTER (
    crm_flat_fees,
    crm_flat_fees[datefrom] > EARLIER ( crm_flat_fees[dateuntil] )
   ),
  ALLEXCEPT(crm_flat_fees, crm_flat_fees[projectid])
)
, BLANK()
)
 
It is working correctly and the result is following (red arrows):
pbiforum.PNG
 
However, I would also like to shift "serviceid" value as indicated by blue arrows. So far I had very little success using FIRSTNONBLANK instead of FIRSTDATE.
Any tips how to do it?
1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Ondra ,

 

If I understand your requirement correctly that you want to calculate the next row for serviceid.

 

You could create a group index column firstly with dax

 

Then create the calculated column with the formula below.

 

Column = 
CALCULATE (
 FIRSTNONBLANK('Table1'[serviceid],1),
 FILTER (
 'Table1',
 'Table1'[Index] =EARLIER ('Table1'[Index] )-1
 )
)

Here is the output.

 

Capture.PNG

 

You could have a look at this blog to know more about FIRSTNOBLANK().

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Ondra ,

 

If I understand your requirement correctly that you want to calculate the next row for serviceid.

 

You could create a group index column firstly with dax

 

Then create the calculated column with the formula below.

 

Column = 
CALCULATE (
 FIRSTNONBLANK('Table1'[serviceid],1),
 FILTER (
 'Table1',
 'Table1'[Index] =EARLIER ('Table1'[Index] )-1
 )
)

Here is the output.

 

Capture.PNG

 

You could have a look at this blog to know more about FIRSTNOBLANK().

 

Best Regards,

Cherry

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

Thanks! That's what I was looking for 🙂

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.