Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Solved! Go to Solution.
Hi @Anonymous ,
I suggest you to create a "DimDate" table to help calculation.
DimDate =
VAR _CALENDAR =
CALENDARAUTO()
RETURN
ADDCOLUMNS (
_CALENDAR,
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"MonthName", FORMAT ( [Date], "MMMM" ),
"RANKX",
RANKX ( _CALENDAR, YEAR ( [Date] ) * 100 + MONTH ( [Date] ),, ASC, DENSE )
)
Measure:
Sum 3 month count =
VAR _SUMMARIZE =
SUMMARIZE (
ALL ( DimDate ),
DimDate[Year],
DimDate[MonthName],
DimDate[RANKX],
"P1M", [p1m]
)
RETURN
SUMX (
FILTER (
_SUMMARIZE,
[RANKX]
> MAX ( DimDate[RANKX] ) - 3
&& [RANKX] <= MAX ( DimDate[RANKX] )
),
[P1M]
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
I suggest you to create a "DimDate" table to help calculation.
DimDate =
VAR _CALENDAR =
CALENDARAUTO()
RETURN
ADDCOLUMNS (
_CALENDAR,
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"MonthName", FORMAT ( [Date], "MMMM" ),
"RANKX",
RANKX ( _CALENDAR, YEAR ( [Date] ) * 100 + MONTH ( [Date] ),, ASC, DENSE )
)
Measure:
Sum 3 month count =
VAR _SUMMARIZE =
SUMMARIZE (
ALL ( DimDate ),
DimDate[Year],
DimDate[MonthName],
DimDate[RANKX],
"P1M", [p1m]
)
RETURN
SUMX (
FILTER (
_SUMMARIZE,
[RANKX]
> MAX ( DimDate[RANKX] ) - 3
&& [RANKX] <= MAX ( DimDate[RANKX] )
),
[P1M]
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
pls try this
CURRENT MONTH nov =
VAR _Start = EOMONTH(TODAY(),-1)+1
VAR _End = EOMONTH(TODAY(),0)
RETURN
CALCULATE([p1m], DATESBETWEEN('Calendar'[Date],_Start,_End)
-------------
Last 1 MONTH Oct =
VAR _Start = EOMONTH(TODAY(),-2)+1
VAR _End = EOMONTH(TODAY(),-1)
RETURN
CALCULATE([p1m], DATESBETWEEN('Calendar'[Date],_Start,_End)
------------
Last 2 MONTH Sept=
VAR _Start = EOMONTH(TODAY(),-3)+1
VAR _End = EOMONTH(TODAY(),-2)
RETURN
CALCULATE([p1m], DATESBETWEEN('Calendar'[Date],_Start,_End)
Hello @Anonymous ,
Firstly create a calendar table and create relationship with your fact table.
Then use below calculation by modifying table names as per your data.
Cal_Measure =
Var CM = CALCULATE(DISTINCTCOUNT(PSR[customer_code]), Filter(Calendar_Table, 'Calendar_Table'[Month] = Month(Today())))
Var PM = CALCULATE(DISTINCTCOUNT(PSR[customer_code]), Filter(Calendar_Table, 'Calendar_Table'[Month] = Month(Today())-1))
Var PPM = CALCULATE(DISTINCTCOUNT(PSR[customer_code]), Filter(Calendar_Table, 'Calendar_Table'[Month] = Month(Today())-2))
Return
CM+PM+PPM
If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!
not displaying anything
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!