Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet 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
I'm still a pretty new BI user, coming from years of excel experience, so I'm still trying to learn the DAX/excel formula crossover.
I have a dataset of transaction dates, pulling invoice and receipt data, identified by the TransType of IN (invoice) and CR (cash receipt). I'm wanting to create a calculated column that shows me the invoice date, because my data set ONLY has the transaction date.
What I would expect in excel would be an IF formula with a nested INDEX to lookup the transaction date of the Invoice line: "IF(TransType = "IN",TransDate,INDEX(TransDate,MATCH(invoice218978,Invoice,0))). Not having the Index-Match option in BI is hurting me. Basically what I'm wanting is, if the transaction is "IN", make the calculated column InvDate equal the TransDate of that line. If it's a "CR" transaction, lookup the invoice number from within the dataset and pull back the TransDate from the corresponding "IN" transaction.
Here's an example of the dataset that I have:
TransactionType | TransactionDate | TransactionAmount | InvoiceNumber | INVDATE |
IN | 2/10/2022 | 4025 | 218978 | =inv218978 TransType IN TransDate |
CR | 4/18/2022 | 4025 | 218978 | =inv218978 TransType IN TransDate |
IN | 2/15/2022 | 1926 | 219105 | =inv219105 TransType IN TransDate |
IN | 2/15/2022 | 6854 | 219106 | =inv219106 TransType IN TransDate |
CR | 4/19/2022 | 1926 | 219105 | =inv219105 TransType IN TransDate |
Any insight on this, even if it's to tell me I'm way off would be extremely appreciated!
Solved! Go to Solution.
Hi @vandelD ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a calculated column as below:
INVDATE =
CALCULATE (
MAX ( 'Table'[TransactionDate] ),
FILTER (
'Table',
'Table'[InvoiceNumber] = EARLIER ( 'Table'[InvoiceNumber] )
&& 'Table'[TransactionType] = "IN"
)
)
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi @vandelD ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a calculated column as below:
INVDATE =
CALCULATE (
MAX ( 'Table'[TransactionDate] ),
FILTER (
'Table',
'Table'[InvoiceNumber] = EARLIER ( 'Table'[InvoiceNumber] )
&& 'Table'[TransactionType] = "IN"
)
)
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
This seems to work, thank you so much for the help!
InvDate = IF( 'Table'[Transaction Type] = "IN", 'Table'[Transaction Date],
var invNumber = 'Table'[Invoice Number]
return LOOKUPVALUE( 'Table'[Transaction Date], 'Table'[Invoice Number], invNumber, 'Table'[Transaction Type], "IN")
)
Thanks for the feedback, johnt75, I think this got me very close. I got an error that multiple values were returned where a single value was expected. I'm thinking this is due to the fact that a single invoice number can show appear mutliple times in the dataset if there were multiple lines invoiced. Any suggestions for working around the duplicates? Thanks!
you could try wrapping the LOOKUPVALUE in DISTINCT()
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
83 | |
71 | |
49 |
User | Count |
---|---|
143 | |
120 | |
110 | |
59 | |
57 |