Forum Discussion
Continuous Years
Hello, I have created the below measure to calcuate continuous years of giving.
10 Replies
- amitchandakSuper User
Anonymous , try this change
AR __Previous = MAXX(FILTER(allselected('Gifts (2)'),'Gifts (2)'[constituent_id] = max('Gifts (2)'[constituent_id]) && [Financial Year] < max('Gifts (2)'[Financial Year])),'Gifts (2)'[Financial Year])
RETURN [Financial Year] - __PreviousCan you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
- AnonymousNot applicable
Still not working, as the same error before.;
ID Date Financial Year 1111111 January 2009 FY9 12434345 Aug 2010 FY11 34324234 12 Aug 2009 FY10 1111111 January 2010 FY10 351241 February 1978 FY78 6834347 February 1978 FY78 1111111 January 2009 FY9 12434545 August 2009 FY9 I'm wanting the FY9 to be displayed as FY09 and I am wanting to know the continuous years of gifting based on ID across Financial Years, they have to be continuous give across financial years to be classed as continuous donors. For instance, an ID that has gifted for FY 78, 79 and 80 would be 3 years of conitiunous donating.
- v-chenwuz-msftCommunity Support
Hi Anonymous,
The reason why it shows FY9 for 2009 instead of FY09 is that the Function VALUE()
The FORMAT() you used will return a text type 09, but when the text input VALUE(), it will be translated to a number 9.
Use this dax to create a column named Financial Year:
Financial Year = VAR A = IF( [DATE].[MonthNo] > 8, FORMAT( DATE( YEAR( [DATE] ) + 1, 1, 1 ), "yy" ), FORMAT( [DATE], "yy" ) ) RETURN CONCATENATE( "FY", A )Going back to your case, you need to calculate the number of years it lasts.
Create a column which is useful for calculations:
Fyear = IF( MONTH( [DATE] ) > 8, YEAR( [DATE] ) + 1, YEAR( [DATE] ) )Try this measure to count the number of years of conitiunous donating:
Continuous Years = VAR _IDGroupTable = FILTER( ALL( 'Table' ), [ID] = SELECTEDVALUE( 'Table'[ID] ) ) VAR _AConY = MAXX( _IDGroupTable, [Fyear] ) - MINX( _IDGroupTable, [Fyear] ) + 1 VAR _FConY = COUNTROWS( DISTINCT( SUMMARIZE( _IDGroupTable, 'Table'[ID], 'Table'[Fyear] ) ) ) RETURN IF( _AConY = _FConY, _FConY, BLANK() )Here is my pbix file ,you can reference.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
This is sort of working, there is an individual that is showing as donating over 27 years, but its showing as blank on the power bi report.
- AnonymousNot applicable
This appears to only look at number of years donating and not continuous. I forgot to mention it is only classed as continuous years by donating every year until the current year.
- PaulDBrownCommunity Champion
Can you clarify the criteria? You say "it is only classed as continuous years by donating every year until the current year"
Since you have dates going back to 1970, is it only continuous if there is a record per constituent id every year since 1970 until 2021?
- KhushidondaNew Member
May i know how can i convert year column into
0-1
1-2
3-4
5+ year