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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
fedeg
Frequent Visitor

FIRSTNOBLANK ORDER BY COLUMN

Buenas tardes.

 

Mi modelo de datos tiene las siguientes columnas:

deuda/numero, monto_maximo_pesos, fecha_ingreso, fecha_devuelto

 

La realidad es que por cada deuda/numero, tengo varias filas con distintos monto_maximo_pesos, fecha_ingreso, fecha_devuelto.

Yo quiero sumar un unico monto por deuda/numero, contando unicamente el primero ordenado por fecha_ingreso.

Estoy intentando hacer esto con FIRSTNOBLANK pero el orden que le da, segun fecha_ingreso parece aleatorio. Es posible ordenar la tabla antes de encontrar el primer valor? (desde Power Query no he podido hacerlo, ya que son millones de regristros)

 

Desde ya muchas gracias:

 

Monto Asignado =
CALCULATE(
             SUMX(
                        SUMMARIZE(
                                             'TABLA',
                                             'TABLA'[Numero/Deuda],
                                              "PrimerMontoMinimo",
                                               CALCULATE(
                                                                   FIRSTNONBLANK('TABLA'[monto_maximo_pesos], 1),
                                                                   (
                                                                     'TABLA'[fecha_ingreso] <= MIN(Calendario[Fecha]) && 'TABLA'[fecha_devuelto] >= MIN(Calendario[Fecha])
) ||
(
                                                                   'TABLA'[fecha_ingreso] >= MIN(Calendario[Fecha]) && 'TABLA'[fecha_ingreso] <= MAX(Calendario[Fecha])
)
)
),
[PrimerMontoMinimo]
)
)
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@fedeg , I am not sure about the need for a date filter. Most for such join date/calendar table should be disconnected

 

You can use Index Function for 1st value

 

calculate(Min(Table['TABLA'[monto_maximo_pesos]]), index(1, allselected('TABLA'[Numero/Deuda],'TABLA'[fecha_ingreso]), orderBy('TABLA'[fecha_ingreso], desc) ,partitionBy('TABLA'[Numero/Deuda])))

 

Continue to explore Power BI Index function: Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

 

 

Filter are attached two different ways to handle two dates

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @fedeg ,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@fedeg , I am not sure about the need for a date filter. Most for such join date/calendar table should be disconnected

 

You can use Index Function for 1st value

 

calculate(Min(Table['TABLA'[monto_maximo_pesos]]), index(1, allselected('TABLA'[Numero/Deuda],'TABLA'[fecha_ingreso]), orderBy('TABLA'[fecha_ingreso], desc) ,partitionBy('TABLA'[Numero/Deuda])))

 

Continue to explore Power BI Index function: Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

 

 

Filter are attached two different ways to handle two dates

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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