Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
NilR
Post Patron
Post Patron

RANKX doesn't reset on skipped months!

Start_Dates must be consecutive otherwise the count should be re-started. how can I do that? Thank!

 

 

 

 

Active_records_last_22_months = 
var _GP# = '0200 AW'[GP#]
var _id = '0200 AW'[CID]
var _end_date = '0200 AW'[Start_Date]
var _start_date = EOMONTH(_end_date,-24)+1

VAR _COUNT = RANKX ( 
        FILTER (ALL('TBL'),
            'TBL'[GP#] = EARLIER('TBL'[GP#])
            && '0200 AW'[CID] = EARLIER('TBL'[CID])
            && '0200 AW'[MALES_UNDER_35] = EARLIER('TBL'[MALES_UNDER_35])
            && '0200 AW'[Start_Date] >= _start_date
            && '0200 AW'[Start_Date] <= _end_date
            
        ),        
        '0200 AW'[Start_Date],
        ,
        ASC,
        Dense
    )
 RETURN 
 
_COUNT

 

 

 

 

 

GP#CIDGNDRAGEMOSWELLActive_records_last_22_monthsResult - neededMALES_UNDER_35Start_Date
23425****F35-441011NO03/01/2021
23425****F35-441022NO04/01/2021
23425****F35-441033NO05/01/2021
23425****F35-441044NO06/01/2021
23425****F35-441055NO07/01/2021
23425****F35-441055NO07/01/2021
23425****F35-441066NO08/01/2021
23425****F35-441066NO08/01/2021
23425****F35-441077NO09/01/2021
23425****F35-441088NO10/01/2021
23425****F35-441099NO11/01/2021
23425****F35-44101010NO12/01/2021
23425****F35-44101111NO01/01/2022
23425****F35-44101212NO02/01/2022
23425****F35-44101313NO03/01/2022
23425****F35-44101414NO04/01/2022
23425****F35-4410151NO09/01/2022
23425****F35-4410162NO10/01/2022
23425****F35-4410173NO11/01/2022
23425****F35-4410184NO12/01/2022
23425****F35-4410195NO01/01/2023
23425****F35-4410206NO02/01/2023
23425****F35-4410207NO03/01/2023
23425****F35-4410208NO04/01/2023
23425****F35-4410209NO05/01/2023
23425****F35-44102010NO06/01/2023

 

 

1 REPLY 1
ryan_mayu
Super User
Super User

@NilR 

you can create two columns 

Column = 
VAR _max=maxx(FILTER('Table','Table'[Start_Date]<EARLIER('Table'[Start_Date])),'Table'[Start_Date])
return if(EDATE('Table'[Start_Date],-1)=_max,0,1)


result = 
VAR _last=maxx(FILTER('Table','Table'[Start_Date]<=EARLIER('Table'[Start_Date])&&'Table'[Column]=1),'Table'[Start_Date])
VAR _sort=CALCULATE(DISTINCTCOUNT('Table'[Start_Date]),FILTER('Table','Table'[Start_Date]<=EARLIER('Table'[Start_Date])&&'Table'[Start_Date]>=_last))
return _sort

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.