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

Index Match through Power Query or DAX

I hope there is someone who ran into this and has found a solution. 

 

I am importing a table in PowerBI where I have several columns with: Name,  Invoice Number, Code, Invoice Date, Invoice Due Date. The issue I have is that on some rows the Invoice Due Date is blank, when it should match the Invoice Due Date from other rows, as long as it is the same Invoice Number. This blank Invoice Due Date happens only when the Code is F or T, when it is a P there will always be a date. I need the Invoice Due Date populated to match based on the Invoice Number and Code = P (there can be several rows with these two criteria, not just one, but the due date will always be the same). 

 

I don't want to use Group By because I need the table in this format, I have many more columns that I don't want to group, there are other invoice details tracked by each row which cannot be aggregated and I need for other reasons. I hope there is a way to create a calculated column and find the corresponding Invoice Due Date based on a matching Vendor Invoice Number and Trans Code being P.

 

Thanks so much!

No     Name                  Invoice Number Invoice Date  CodeInvoice Due DateAging
1ABC TECHNOLOGIES1234569/10/2021P10/15/202147
1ABC TECHNOLOGIES1234569/10/2021P10/15/202147
1ABC TECHNOLOGIES1234569/10/2021F  
1ABC TECHNOLOGIES1234569/10/2021F  
2MAGICAL LABSRU78910119/11/2021P10/18/202149
2MAGICAL LABSRU78910119/12/2021P10/18/202149
2MAGICAL LABSRU78910119/13/2021T  
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Oana , try

new column =
var _max = maxx(filter(Table, [Invoice Number] = earlier([Invoice Number]) ), [Invoice Due Date])
return
if( isblank([Invoice Due Date]), _max, [Invoice Due Date])

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Picture1.png

 

Due Date Aging CC =
VAR currentinvoicenumber = Data[Invoice Number]
VAR duedate =
MAXX (
FILTER ( Data, Data[Invoice Number] = currentinvoicenumber ),
Data[Invoice Due Date]
)
RETURN
INT ( TODAY () - duedate )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi Jihwan, thank you for your DAX solution, it really close to what I was looking for, but it calculated Aging based on TODAY(), which is a different interval. I was looking for the same Invoice Due Date to be copied over in the blanks based on Invoice Number. The solution below worked, I do appreciate it though!

amitchandak
Super User
Super User

@Oana , try

new column =
var _max = maxx(filter(Table, [Invoice Number] = earlier([Invoice Number]) ), [Invoice Due Date])
return
if( isblank([Invoice Due Date]), _max, [Invoice Due Date])

This was great, it worked perfectly, it filled in all blank Invoice Due Date with a date! Keep on the great work @amitchandak !!!

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.