Forum Discussion
Marshmallow
1 year agoHelper II
return value (text format) for previous qtr
Hi, I need help with dax formula to return previous period with this messy data that I have. Can someone please help? Below is my data (sample) Region Company Type Period Rating Sydney...
- Anonymous1 year ago
Hi Marshmallow ,
Please try this way:
First use this DAX to create a calculated column:RANK = VAR _Region = [Region] VAR _Company = [Company] VAR _Type = [Type] RETURN RANKX( FILTER( ALL('Table'), 'Table'[Region] = _Region && 'Table'[Company] = _Company && 'Table'[Type] = _Type ), 'Table'[Period], , DESC, Dense )Then use this DAX to create another calculated column:
Previous Qtr = VAR _Region = [Region] VAR _Company = [Company] VAR _Type = [Type] VAR _Rank = [RANK] RETURN CALCULATE( MAX('Table'[Rating]), ALL('Table'), 'Table'[Region] = _Region && 'Table'[Company] = _Company && 'Table'[Type] = _Type && 'Table'[RANK] = _Rank + 1 )And the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
1 year agoNot applicable
Hi Marshmallow ,
Please try this way:
First use this DAX to create a calculated column:
RANK =
VAR _Region = [Region]
VAR _Company = [Company]
VAR _Type = [Type]
RETURN
RANKX(
FILTER(
ALL('Table'),
'Table'[Region] = _Region && 'Table'[Company] = _Company && 'Table'[Type] = _Type
),
'Table'[Period],
,
DESC,
Dense
)
Then use this DAX to create another calculated column:
Previous Qtr =
VAR _Region = [Region]
VAR _Company = [Company]
VAR _Type = [Type]
VAR _Rank = [RANK]
RETURN
CALCULATE(
MAX('Table'[Rating]),
ALL('Table'),
'Table'[Region] = _Region && 'Table'[Company] = _Company && 'Table'[Type] = _Type && 'Table'[RANK] = _Rank + 1
)
And the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Marshmallow
1 year agoHelper II
Thank you, it works 🙂