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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Abs_N
Frequent Visitor

DAX Measure to calculate month end value dynamically

Hi,

I have power bi report and would like to create a DAX measure to calculate the SLA % of the total but for the last month dynamically.

Here is a sample of my data:


Month Year       Within        SLA Total           % within SLA
Sep-21                    10              50                      20
Oct-21                      5               50                      10
Nov-21                     7             100                         7

 

I would like to create a measure to work out the Nov21 % SLA
but I would like the calculation to be dynamic so that is uses the last month measure.

So when we run the report is run again in say January it uses Dec21 for calculating the %SLA.

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Abs_N ,

 

According to your description, I think you are going to calculate the ratio value for the previous month.

 

You can try this measure:

% previous month = var _start=EOMONTH(TODAY(),-2)
var _end=EOMONTH(TODAY(),-1)
return DIVIDE(CALCULATE(SUM('Table'[Within]),FILTER('Table',[Month Year]<=_end&&[Month Year]>_start)),CALCULATE(SUM('Table'[SLA Total]),FILTER('Table',[Month Year]<=_end&&[Month Year]>_start)))

EOMONTH function returns the date in datetime format of the last day of the month, before or after a specified number of months.

Here's the result.

vstephenmsft_0-1639460824305.png

 

Best Regards,

Stephen Tao

 

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

 

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Abs_N ,

 

According to your description, I think you are going to calculate the ratio value for the previous month.

 

You can try this measure:

% previous month = var _start=EOMONTH(TODAY(),-2)
var _end=EOMONTH(TODAY(),-1)
return DIVIDE(CALCULATE(SUM('Table'[Within]),FILTER('Table',[Month Year]<=_end&&[Month Year]>_start)),CALCULATE(SUM('Table'[SLA Total]),FILTER('Table',[Month Year]<=_end&&[Month Year]>_start)))

EOMONTH function returns the date in datetime format of the last day of the month, before or after a specified number of months.

Here's the result.

vstephenmsft_0-1639460824305.png

 

Best Regards,

Stephen Tao

 

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

 

 

Abs_N
Frequent Visitor

Hi @Greg_Deckler ,

 

no the percentage is 7% however I want the calculation to be dynamic in that it always uses the month end measure

so say we have a card for this month end measure and it will return 7% 
then when we run the report again after month and the dataset has Decemeber data the card will automatically pick up Decemebers data and show the new %. 

 

I want the measure to the automatically use the latest month data.

@Abs_N Oh, then you just need Lookup Min/Max where you find your max date value and then grab the items from that row, like below. Best if you have an actual date column or index column to find the "max".

Measure =
  VAR __Last = MAX('Table'[Month Year])
  VAR __Within = MAXX(FILTER('Table',[Month Year]=__Last),[Within])
  VAR __SLATotal = MAXX(FILTER('Table',[Month Year]=__Last),[SLA Total])
RETURN
  __Within / __SLATotal * 100

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 
I think we are nearly there . . .

The underlying data is as follows 

 

Month YearWithinTotal
Sep-2101
Oct-2111
Nov-2111

 

The original table is a summary 

 

The "Within" is a sum and the total is a count of all the items.

I have tried checking the within variable but I think my syntax is incorrect.
Here is what I have at the moment . . 

LastMonthPercentage =
VAR __Last = max('AlertData'[Period])
VAR __Within = MAXX(FILTER('AlertData',[Period])=__Last, sum(AlertData[WithinSLA]))
RETURN
__Within
 
ERROR - The expression refers to multiple columns. multiple columns cannot be converted to a scalar value

 

 

Greg_Deckler
Community Champion
Community Champion

@Abs_N So are you saying that for November that the % within SLA should be 10%, not 7%?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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 Kudoed Authors