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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kasife
Helper V
Helper V

Sort column using offset function

Hi Guys,
I created this function and it's working fine, but it's bringing the result based on the order of the projects and I would like the result to be sorted by the "Data PJ" column. How could I resolve?

I try to change the orderby using the Assinatura "PJ " column but I get an error

 

 

_OFFSET data PJ = 

VAR Datapj = MAX(Ultimo_Reaal[Assinatura PJ])
RETURN
IF(Datapj<>BLANK(),
    CALCULATE(
   MAX(Ultimo_Reaal[Assinatura PJ]),
        OFFSET(+1,
        ALLSELECTED(Ultimo_Reaal[Nome do Projeto Original]),
        ORDERBY(Ultimo_Reaal[Nome do Projeto Original],ASC))))

 

 

 

kasife_0-1684331855749.png

 

2 REPLIES 2
kasife
Helper V
Helper V

@amitchandak 

Now my dates are gone. In the previous function it was bringing it correctly, but it was doing the function based on the order of the projects only and I wanted it to do it based on the order of the Date PJ too.

kasife_0-1684335894452.png

 

amitchandak
Super User
Super User

@kasife , It need to part of the relation

_OFFSET data PJ =

VAR Datapj = MAX(Ultimo_Reaal[Assinatura PJ])
RETURN
IF(Datapj<>BLANK(),
CALCULATE(
MAX(Ultimo_Reaal[Assinatura PJ]),
OFFSET(+1,
ALLSELECTED(Ultimo_Reaal[Nome do Projeto Original],Ultimo_Reaal[Data PJ] ),
ORDERBY(Ultimo_Reaal[Data PJ],ASC))))

 

April 2023 onward, measures can be used outside the relation/table  in order by

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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