Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I am using direct query in my report. I have currently 4 tables:
- Standard Dim_Date
- Fact_Table with shape:
| Account_ID | Transaction_ID | Transaction_Date | Transaction_Value |
| 1 | a | 4/25/2025 | 20 |
| 1 | b | 5/25/2025 | 30 |
| 2 | c | 3/25/2025 | 40 |
| 2 | d | 5/25/2025 | 50 |
- Current Account_Dim Master Data
| Account_ID | Account Type | Owner |
| 1 | Big | XYZ |
| 2 | Small | ABC |
- Historical_Account _Dim, monthly level granularity with index, month star and end date.
| Account_ID | Account_Type | Owner | Start_Date | End_date | Index |
| 1 | Big | XYZ | 4/1/2025 | 4/30/2025 | 1001 |
| 1 | Small | XYZ | 5/1/2025 | 5/31/2025 | 1002 |
| 2 | Small | ABC | 4/1/2025 | 4/30/2025 | 1003 |
| 2 | Medium | ABC | 5/1/2025 | 5/31/2025 | 1004 |
I wanted to create a calculated column in Fact Table to add Index from Historical Account Dim to create connection and be able to filter visuals at report not with Current Account Dim but Historical Account Dim.
My dax code was:
Due to Direct Query mode I cannot use Calculate in Calculated Column. Is there a workaround to receive calculated column with same results as my code, but keep Direct Query mode? Thank you in advance
Solved! Go to Solution.
Hello,
Thank you for help @rohit1991 - your solution also only work in Import mode. But I found workaround.
In Power Query I wrote manual SQL code. I created foreign key using Account_ID and first date of month in tables:
- Historical_Account _Dim
- Fact_Table (used Transaction Date to get first day of month)
With new key I was ablo to retrieve data. @Anonymous Case can be closed
Hi @Pawel_1990
That's great to hear that your issue has been resolved. Please accept it as the solution so that it might be helpful for other community members with similar issues to solve it faster.
Thank you.
Hello,
Thank you for help @rohit1991 - your solution also only work in Import mode. But I found workaround.
In Power Query I wrote manual SQL code. I created foreign key using Account_ID and first date of month in tables:
- Historical_Account _Dim
- Fact_Table (used Transaction Date to get first day of month)
With new key I was ablo to retrieve data. @Anonymous Case can be closed
Hi @Pawel_1990
I wanted to check if you had the opportunity to review the information provided by @rohit1991 . Please feel free to contact us if you have any further questions. If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
Hi @Pawel_1990
Thank you for reaching out microsoft fabric community forum.
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @Pawel_1990 ,
In Power BI using DirectQuery mode, creating a calculated column in the Fact Table with complex DAX functions like CALCULATE is not supported because these functions cannot be directly translated into SQL queries. In your scenario, you want to retrieve the correct Index from the Historical_Account_Dim table by matching on Account_ID and checking if the Transaction_Date falls within the Start_Date and End_Date range.
Since you cannot do this using DAX in a calculated column, the recommended workaround is to perform this logic in Power Query (M) using a custom row-by-row join. This can be done by loading both the Fact and Historical tables into Power Query and then writing a custom column that filters the appropriate matching rows from the historical table. After filtering, you can expand the result to pull in the Index column, which will replicate the same outcome as your original DAX code, while staying fully compatible with DirectQuery limitations.
Here’s the Power Query (M) code you can use inside Power BI:
// Step 1: Add a custom column to Fact_Table that filters matching historical records
= Table.AddColumn(Fact_Table, "JoinKey", each
Table.SelectRows(Historical_Account_Dim,
(h) => [Account_ID] = h[Account_ID] and
[Transaction_Date] >= h[Start_Date] and
[Transaction_Date] <= h[End_Date]))
// Step 2: Expand the Index column from the JoinKey table
= Table.ExpandTableColumn(#"Previous Step Name", "JoinKey", {"Index"}, {"Historical_Index"})
Additionaly, just to clarify, when I switched tables to import mode, everything worked as expected 🙂
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 45 | |
| 42 | |
| 21 | |
| 18 |