Forum Discussion
Calculating Prior Year Values
Hi,
I tried to create a DAX formula based on what I got from the question.
Please check if it suits your datamodel.
Prior year New Player Numbers =
VAR _currentyear =
MAX ( 'Date Table'[Season] )
VAR _prioryear = _currentyear - 1
VAR _prioryearregisterlist =
CALCULATETABLE (
SUMMARIZE ( 'Player Registrations', 'Player Registrations'[Person ID] ),
'Date Table'[Season] = _prioryear
)
VAR _previousofprioryearregisterlist =
CALCULATETABLE (
SUMMARIZE ( 'Player Registrations', 'Player Registrations'[Person ID] ),
'Date Table'[Season] < _prioryear
)
RETURN
COUNTROWS (
EXCEPT ( _prioryearregisterlist, _previousofprioryearregisterlist )
)
It is close, and certainly better than my attempts, but the numbers are not lining up. See the table below
What would the Prior Year Returning Player formula look like as well?
- Jihwan_Kim3 years agoSuper User
Hi,
Thank you for your message.
Please provide a link of the sample pbix file, and then I can try to look into it to come up with a more accurate solution.
Thanks.
- RNZALR3 years agoHelper I
I have emailed you the file to the address you gave me last time. Thank you!
- Jihwan_Kim3 years agoSuper User
Hi,
Thank you.
I am not sure which one is the desired output, but please check the below.
In each measure, two different columns from two different tables are used in the comparison.
Player Registrations[Person ID] or Player Master[Person ID] ???
fix the [New Player Numbers] measure,
New Player Numbers = VAR _currentyear = MAX ( 'Date Table'[Season] ) VAR _registerlist = SUMMARIZE ( 'Player Registrations', 'Player Registrations'[Person ID] ) VAR _previousregisterlist = CALCULATETABLE ( SUMMARIZE ( 'Player Registrations', 'Player Registrations'[Person ID] ), 'Date Table'[Season]< _currentyear ) RETURN COUNTROWS ( EXCEPT ( _registerlist, _previousregisterlist ) )or,
fix the [Prior year New Player Numbers] measure.
Prior year New Player Numbers = VAR _currentyear = MAX ( 'Date Table'[Season] ) VAR _prioryear = _currentyear - 1 VAR _prioryearregisterlist = CALCULATETABLE ( SUMMARIZE ( 'Player Registrations', 'Player Master'[Person ID] ), 'Date Table'[Season] = _prioryear ) VAR _previousofprioryearregisterlist = CALCULATETABLE ( SUMMARIZE ( 'Player Registrations', 'Player Registrations'[Person ID] ), 'Date Table'[Season] < _prioryear ) RETURN COUNTROWS ( EXCEPT ( _prioryearregisterlist, _previousofprioryearregisterlist ) )