Date Dimension Power bi

Dates = 

VAR CurrentDate = TODAY()
RETURN

ADDCOLUMNS (
CALENDAR( DATE( 1900; 1; 1); DATE( 2022; 12; 31 ) );

"Year"; YEAR([Date]);

"Month in Year"; MONTH([Date]);

"Month"; FORMAT([Date];"mmm");

"Quarter in Year"; QUARTER([Date]);

"Quarter"; CONCATENATE("Q"; QUARTER([Date]) );

"Month & Year Sort"; FORMAT( [Date]; "yyyymm" );

"Month & Year"; FORMAT([Date];"MMM yyyy");

"Month Offset"; DATEDIFF( CurrentDate; [Date]; MONTH );

"Date Offset"; DATEDIFF( CurrentDate; [Date]; DAY )

)


Max Selected Date (in context) = 

MAXX(

KEEPFILTERS(

VALUES( Dates[Date] )

);

CALCULATE(

MIN( Dates[Date] )

)

)


Min Selected Date (in context) = 

MINX(

KEEPFILTERS(

VALUES( Dates[Date] )

);

CALCULATE(

MIN( Dates[Date] )

)

)



BankCountNewCustomers = 
//COUNTROWS(FILTER(Customers, Customers[DateRegistered].[Year] >= [NewRegisteredMeasure])) + 0
var MINDATE = [Min Selected Date (in context)]
VAR MAXDATE  = [Max Selected Date (in context)]
var datasetd = CALCULATETABLE(
values(Customers[gid]); Customers[DateRegistered] >= MINDATE && Customers[DateRegistered] <= MAXDATE) 
return 
CALCULATE([BankCountAllCustomers]; datasetd)