Forum Discussion
AltGr9
Helper I
5 years agoshow week by date selection
Hi all, This is what I'm tyring to get to: I have tried a DAX measure that puts the max date in a variable (to get the slicer's date) and then in another variable t...
- 5 years ago
Hi, ok, I've found a solution to my problem.
Here it is for anyone struggling with the same issue:
- I already had a Date Dimension table related to my Fact table, so I Duplicated it to create two Date Dimension tables
- On the Date Duplicate table, I ensured there were no relationships between this table and my fact table
- I created a date slicer based on the Date column of the Date Duplicate table, setting the slicer to Before
- In my Fact table I created a new calculated column (not measure) to bring over the index that I had on my Date table, as follows:
- Date Index = MAXX( RELATEDTABLE('Dimension Date'), 'Dimension Date'[Index] )
- I created a duplicate date column in my original Date table and formatted it to Data type Date, and Format dddd in the Column tools part of the ribbon:
- Day = 'Dimension Date'[Date]
- I created the following measure in my Fact table, ensuring I set the data type to Decimal and the Format to decimal with 2 decimal places in the measure tools ribbon:
- Actual Measure =VAR _SelectedValue = MAX('Date Duplicate'[Date])VAR _DateIndex = CALCULATE( MAX('Date Duplicate'[Index]), 'Date Duplicate'[Date] = _SelectedValue )VAR _DateIndexMinus7 = _DateIndex -7VAR _MaxIncrement = MAX('Fact'[Date Index])VAR _MaxActual = MAX('Fact'[Actual])RETURNIF(AND(_MaxIncrement <= _DateIndex, _MaxIncrement > _DateIndexMinus7), _MaxActual, BLANK())
- I created a Clustered Column chart Visual setting the Axis to my new Day column (created above) and the Values to the Actual Measure in the Fact table
- I set the Day column in the Visual to Day not Date Hierarchy
- I set the X Axis Type to Categorical
- I removed the X and Y axis titles.
- Done.
AltGr9
Helper I
5 years agoHi, ok, I've found a solution to my problem.
Here it is for anyone struggling with the same issue:
- I already had a Date Dimension table related to my Fact table, so I Duplicated it to create two Date Dimension tables
- On the Date Duplicate table, I ensured there were no relationships between this table and my fact table
- I created a date slicer based on the Date column of the Date Duplicate table, setting the slicer to Before
- In my Fact table I created a new calculated column (not measure) to bring over the index that I had on my Date table, as follows:
- Date Index = MAXX( RELATEDTABLE('Dimension Date'), 'Dimension Date'[Index] )
- I created a duplicate date column in my original Date table and formatted it to Data type Date, and Format dddd in the Column tools part of the ribbon:
- Day = 'Dimension Date'[Date]
- I created the following measure in my Fact table, ensuring I set the data type to Decimal and the Format to decimal with 2 decimal places in the measure tools ribbon:
- Actual Measure =VAR _SelectedValue = MAX('Date Duplicate'[Date])VAR _DateIndex = CALCULATE( MAX('Date Duplicate'[Index]), 'Date Duplicate'[Date] = _SelectedValue )VAR _DateIndexMinus7 = _DateIndex -7VAR _MaxIncrement = MAX('Fact'[Date Index])VAR _MaxActual = MAX('Fact'[Actual])RETURNIF(AND(_MaxIncrement <= _DateIndex, _MaxIncrement > _DateIndexMinus7), _MaxActual, BLANK())
- I created a Clustered Column chart Visual setting the Axis to my new Day column (created above) and the Values to the Actual Measure in the Fact table
- I set the Day column in the Visual to Day not Date Hierarchy
- I set the X Axis Type to Categorical
- I removed the X and Y axis titles.
- Done.