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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Attempting to calculate a total based off end of month date

Hello, I currently have a measure that draws from multiple tables to satisfy an "Active Customer Count" monthly. The measure is as follows.

 

Customers By Area =
CALCULATE (
SUM ( FactActiveCust[Active_Count] ),
ALL ( DimRegions ),
FILTER (
DimRegions,
DimRegions[SubdivisionCode]
= SELECTEDVALUE ( 'Account Master GL'[MainRegCode], BLANK () )
),
ENDOFMONTH ( DimDates[Date] )
)

It might be a little confusing, there were some unconnected queries and so there were multiple steps. It might not be relevant to my question, but I figured I would include it so one of you can offer a solution given the current format.

 

There is currently a "Date Calculated" column, where in January (e.g) there will be a count during 1/1, 1/2, 1/4, 1/7, 1/12.......1/31, for example. It is different each month. However, as long as there is an end of month date, the entire customer count is summarized neatly. Over the past few years, there are a couple of months where the end date falls a few days short. For example, September 2019's last recorded date of count is 9/27. As a result, these monthly counts are showing up as blanks.

short date for pbi comm.pnglong date for pbi comm.png

Ideally: I am looking to modify my measure (if possible) where it counts some sort of MAXDATE, LASTDATE (of month), etc. that ignores the final date of the month and looks towards the last recorded date of the month to summarize.

 

However: If all else fails, I know the numbers that I need, in total it's about 20 locations x 4 months where this probelm occurs, and I am okay with manually entering the data if there is some sort of way. It shouldn't take more than 15 minutes and I would be very happy if this could be resolved by the end of the day.

Thanks!!!

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please also use the following measure:

 

Customers By Area =
VAR a =
    SELECTEDVALUE ( 'Account Master GL'[MainRegCode], BLANK () )
VAR b =
    MAX ( DimRegions[Date Calculated] )
RETURN
    CALCULATE (
        SUM ( FactActiveCust[Active_Count] ),
        ALL ( DimRegions ),
        DimRegions[SubdivisionCode] = a,
        DimRegions[Date Calculated] = b
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please also use the following measure:

 

Customers By Area =
VAR a =
    SELECTEDVALUE ( 'Account Master GL'[MainRegCode], BLANK () )
VAR b =
    MAX ( DimRegions[Date Calculated] )
RETURN
    CALCULATE (
        SUM ( FactActiveCust[Active_Count] ),
        ALL ( DimRegions ),
        DimRegions[SubdivisionCode] = a,
        DimRegions[Date Calculated] = b
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

lbendlin
Super User
Super User

Do not use SELECTEDVALUE inside a CALCULATE.  Assign a variable, and then use that.

You are calculating under a filter context already so you can simplify your code.

 

Customers By Area =
var a = SELECTEDVALUE ( 'Account Master GL'[MainRegCode], BLANK () )
return CALCULATE (
SUM ( FactActiveCust[Active_Count] ),
ALL ( DimRegions ),
DimRegions[SubdivisionCode] = a,
ENDOFMONTH ( DimDates[Date] )
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors