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.
Hi,
I have created model in "direct query" mode, I dont have experience with it. (I normaly use add Column with combination formulas Calculate + Allexept... now it doesnt work)
I need to add values from one column in "table B" to the "table A" for Column xID.
I have this conditions:
Hi @Kopec ,
Since you are working in DirectQuery mode, you cannot use CALCULATE + ALLEXCEPT as in Import mode. Instead, you need a DAX approach that works with DirectQuery constraints.
Please try below steps:
1. Identify the Maximum Column Order - 1 for Each xID
You need to determine the (Max(Column Order) - 1) for each xID, which will help you find the corresponding Personal ID.
Create a calculated table (if allowed) or use a variable in a measure:
MaxOrderMinus1 =
VAR MaxOrderTable =
SUMMARIZE ( 'Table A', 'Table A'[xID], "MaxOrder", MAX ( 'Table A'[Column Order] ) - 1 )
RETURN
MaxOrderTable
This will return the maximum Column Order - 1 for each xID.
2. Get the Corresponding Personal ID
Now, filter Table A to retrieve the Personal ID that matches the MaxOrderMinus1 value:
PersonalIDForMaxOrder =
VAR MaxOrder =
LOOKUPVALUE ( MaxOrderMinus1[MaxOrder], MaxOrderMinus1[xID], 'Table A'[xID] )
RETURN
LOOKUPVALUE ( 'Table A'[Personal ID], 'Table A'[xID], 'Table A'[xID], 'Table A'[Column Order], MaxOrder )
This retrieves the Personal ID corresponding to (Max(Column Order) - 1).
3. Lookup the Column Name from Table B
Once you have the Personal ID, use it to fetch the corresponding Column Name from Table B:
ColumnNameFromTableB =
LOOKUPVALUE ( 'Table B'[Column Name], 'Table B'[Column ID], [PersonalIDForMaxOrder] )
Performance Considerations:
Since Table A has 23M+ rows, calculations in DirectQuery will be slow. Some optimizations:
Push filtering to the database (avoid calculated columns if possible).
Use aggregations (precompute values in the database).
Use composite models (import only the required fields, use DirectQuery for large data).
Optimize relationships (ensure indexing on xID and Personal ID in the source database).
Please mark this post as solution if it helps you. Appreciate Kudos.
Hi Farhan,
thank you for solution.
I cant use the first step as a table (limit 1 milions rows, for this). Can you show me how to compose to the measure? (I had got a scalar mistakes alert).
Hi @Kopec ,
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
7 | |
6 |