Forum Discussion
Freezing HIstorical Mapping
trathman Create DAX measures to dynamically select the correct hierarchy version
Create a table in Excel or directly in Power BI with columns like:
AccountID
HierarchyLevel1
HierarchyLevel2
HierarchyLevel3
EffectiveStartDate
EffectiveEndDate
Import this table into Power BI.
In the Power BI data model, create a relationship between your transaction data and the versioned hierarchy table based on the AccountID. Additionally, use the transaction date to filter the hierarchy version.
DAX
SelectedHierarchy =
VAR TransactionDate = SELECTEDVALUE('Transactions'[TransactionDate])
RETURN
CALCULATE(
MAX('Hierarchy'[HierarchyLevel1]),
FILTER(
'Hierarchy',
'Hierarchy'[AccountID] = SELECTEDVALUE('Transactions'[AccountID]) &&
'Hierarchy'[EffectiveStartDate] <= TransactionDate &&
'Hierarchy'[EffectiveEndDate] >= TransactionDate
)
)
Use these DAX measures in your report to display the correct hierarchy based on the transaction date.
Thank you for the above. I already have a Many:1 relationship between GLJournal and DIM_Account based on the account number. I am a little confused on how to apply "SelectedHierarchy" in Power BI. I am currently using the Matrix visual with month running across the top:
My hierarchy is structured as:
Would the "SelectedHierarchy" be a piece of my "Total Amount Balance USD Actual" measure?
VAR CalcType = SELECTEDVALUE(DIM_Header[CalcType])