Forum Discussion
Dynamic Matrix Column Switch (Week → Period → Date) using Slicer Not Working
- 8 months ago
Hi HimanshuB,
So you are trying to switch between three completely different SAP fields (not time hierarchies from one dimension) am I right?
Here is Some Approaches That should work for you:
First Approach : Create Unified Date Dimension (This the simplest and Recommended Approach)
DateTable = DISTINCT ( SELECTCOLUMNS ( FactTable, "Date", [Actual Goods Issue Date], "FiscalWeek", [Actual Goods Issue Fiscal Week], "FiscalPeriod", [Actual Goods Issue Fiscal Period] ) )Then:
- Use DateTable[Date] as your primary date field
- Build relationships DateTable[Date] → FactTable[Actual Goods Issue Date]
- Use field parameter with DateTable[Date] , DateTable[FiscalWeek] , DateTable[FiscalPeriod]
Second Approach : Use Calculation Groups (This is More Advanced Approach)
-- Expression 1 (Date): CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP('FactTable'[Actual Goods Issue Date], 'DateTable'[Date]) ) -- Expression 2 (Week): CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP('FactTable'[Actual Goods Issue Fiscal Week], 'WeekTable'[Week]) ) -- Expression 3 (Period): CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP('FactTable'[Actual Goods Issue Fiscal Period], 'PeriodTable'[Period]) )So You need to:
- Create Date Mapping Table in Power Query that links Date ↔ Week ↔ Period
Build Relationships to your fact table
Create Field Parameter from the mapping table columns
Use Slicer on the field parameter for grain selection
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.
Hi Ahmed-Elfeel :
Thanks for your suggestion.
I tried the Field Parameter + Dynamic Measure logic but it still gives composite key error and does not switch correctly.
For clarification:
Last 30 Days → based on Actual Goods Issue Date (SAP field)
Last 5 Weeks → based on Actual Goods Issue Fiscal Week (SAP field)
Last 2 Fiscal Periods → based on Actual Goods Issue Fiscal Period (SAP field)
👉 These 3 logics are already created in SAP HANA, not calculated using DAX.
My goal:
✔ merge all into one matrix and switch columns (Date / Week / Fiscal Period) using slicer.
Question:
🔹 Is it possible to dynamically switch using existing SAP fields?
OR
🔹 Do I need a unified date dimension/calculated mapping to make dynamic switching work?
Looking for the best approach. Thanks.
- Ahmed-Elfeel8 months agoSuper User
Hi HimanshuB,
So you are trying to switch between three completely different SAP fields (not time hierarchies from one dimension) am I right?
Here is Some Approaches That should work for you:
First Approach : Create Unified Date Dimension (This the simplest and Recommended Approach)
DateTable = DISTINCT ( SELECTCOLUMNS ( FactTable, "Date", [Actual Goods Issue Date], "FiscalWeek", [Actual Goods Issue Fiscal Week], "FiscalPeriod", [Actual Goods Issue Fiscal Period] ) )Then:
- Use DateTable[Date] as your primary date field
- Build relationships DateTable[Date] → FactTable[Actual Goods Issue Date]
- Use field parameter with DateTable[Date] , DateTable[FiscalWeek] , DateTable[FiscalPeriod]
Second Approach : Use Calculation Groups (This is More Advanced Approach)
-- Expression 1 (Date): CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP('FactTable'[Actual Goods Issue Date], 'DateTable'[Date]) ) -- Expression 2 (Week): CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP('FactTable'[Actual Goods Issue Fiscal Week], 'WeekTable'[Week]) ) -- Expression 3 (Period): CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP('FactTable'[Actual Goods Issue Fiscal Period], 'PeriodTable'[Period]) )So You need to:
- Create Date Mapping Table in Power Query that links Date ↔ Week ↔ Period
Build Relationships to your fact table
Create Field Parameter from the mapping table columns
Use Slicer on the field parameter for grain selection
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.