Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Would greatly appreicate help with this. I want to add a column to Table 1 that inserts the maximum value of "Invoice #" from that Account/Customer's multipe rows in Table 2. Next I want to populate the third row of Table 1 through look-up to get the "New Charges" value from Table 2 associated with the "Most Recent (max) Invoice" row that we just found (I'll have to match "Customer Number" & "Account Number" and also "Most Recent Invoice" & "Invoice #". I've entered the red values manually to show the desired result. The two tables share the relationship Table 1 (Account Number) == Table 2 (Customer Number). Thanks in advance for any recommendations.
TABLE 1 Account Number |
Most Recent (max) Invoice # |
New Charges from Most Recent Invoice |
123 | AC | 30 |
456 | AD | 40 |
TABLE 2 Customer Number |
Invoice # |
Balance |
New Charges |
123 | AB | 50 | 50 |
123 | AC | 80 | 30 |
123 | AA | 50 | 50 |
456 | AD | 40 | 40 |
456 | AA | 40 | 40 |
456 | AB | 70 | 30 |
456 | AC | 40 | 40 |
Solved! Go to Solution.
Hi @CCConsulting
Can you please follow the below steps and use the dax to get your requirement ?
Since Invoice # is in text format, I am assuming the values are sequential alphabetically.
1. Create a calculated column on table1.
Hi @CCConsulting ,
Thank you for reaching out to Microsoft Fabric community.
Try these Steps -
Create a Relationship
Table1[Account Number] → Table2[Customer Number]
Most Recent (max) Invoice =
CALCULATE (
MAX ( Table2[Invoice] ),
FILTER (
Table2,
Table2[Customer Number] = Table1[Account Number]
)
)
Add Column to Get New Charges for Most Recent Invoice
New Charges from Most Recent Invoice =
VAR RecentInvoice = Table1[Most Recent (max) Invoice]
RETURN
CALCULATE (
MAX ( Table2[New Charges] ),
FILTER (
Table2,
Table2[Customer Number] = Table1[Account Number]
&& Table2[Invoice] = RecentInvoice
)
)
Output -
Please refer the attached .pbix file for your reference.
Regards,
Sreeteja.
Hi @CCConsulting
Can you please follow the below steps and use the dax to get your requirement ?
Since Invoice # is in text format, I am assuming the values are sequential alphabetically.
1. Create a calculated column on table1.
Thanks so much, this yielded exactly what I wanted - BUT when I tried to replicate the Look-Up for an additional column I got the error "A table of multiple values was supplied where a sing value was expected"
I used the DAX code from above for both -only changing the name and the column to pull from. Any ideas what might be the problem?
Thank you for your time and insight!
Here are my two New Columns (using my actual file/column names)
Ah - I tried a new approach - more thinking and less clicking! I looked again at my Table 2 and of the 26,000 rows I had 27 duplicates. After removing them I get both columns populated. I'm not sure why that wouldn't have shown up in the first column and only the second - I guess there is a remote chance that those values were the same and so didn't appear to be a "table of values" where there were perhaps different values in that column of the second case... Something to look into. But thanks again for your time and extremly clear answer/example!
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
11 | |
9 | |
6 |