Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Pawel_1990
Helper I
Helper I

Slowly Changing Dimension and Direct Query

Hello,

I am using direct query in my report. I have currently 4 tables:
- Standard Dim_Date
- Fact_Table with shape:

Account_IDTransaction_IDTransaction_DateTransaction_Value
1a4/25/202520
1b5/25/202530
2c3/25/202540
2d5/25/202550


- Current Account_Dim Master Data

Account_IDAccount TypeOwner
1BigXYZ
2SmallABC


- Historical_Account _Dim, monthly level granularity with index, month star and end date. 

Account_IDAccount_TypeOwnerStart_DateEnd_dateIndex
1BigXYZ4/1/20254/30/20251001
1SmallXYZ5/1/20255/31/20251002
2SmallABC4/1/20254/30/20251003
2MediumABC5/1/20255/31/20251004



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:

TEST_ID =

Calculate(
        MAX(Historical_Account _Dim[Index]),
        FILTER(Historical_Account _Dim,
        Fact_Table[ACCOUNT_ID] = Historical_Account _Dim[Account_ID] &&
        Fact_Table[Transaction_Date] >= Historical_Account _Dim[Start_Date] &&
        Fact_Table[Transaction_Date] <= Historical_Account _Dim[End_Date]
        )
)

QUESTION & PROBLEM:

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 



1 ACCEPTED SOLUTION
Pawel_1990
Helper I
Helper I

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

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.

Pawel_1990
Helper I
Helper I

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

Anonymous
Not applicable

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.

Anonymous
Not applicable

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.

 

rohit1991
Super User
Super User

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"})

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
Pawel_1990
Helper I
Helper I

Additionaly, just to clarify, when I switched tables to import mode, everything worked as expected 🙂 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors