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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
sgeorge930
Regular Visitor

Finding the expiration date (or date of expiry)

Hello,

 

I am working on an issue where I am trying to write a measure to generate an expiration date based on the current average usage of credits within the current month.

 

For example:

DateCredits used
2/1/23      3
2/2/23      2
2/3/23      1
2/4/23      6
2/5/23      5

 

Let's set the monthly credit limit to 30. Total credits used so far is 17 and the average per day so far is 3.4. If we were to then add the total credits used so far to the average per day until you hit the 30 credits limit then the expiry date would be 2/8/23.

 

I just am having issues writing this in a measure as I am confused how to return a date after a calculation.

 

Any help is appreciated!

1 REPLY 1
BrianConnelly
Resolver III
Resolver III

I used a datetable, but try this as I broke down each step...

Exp. Date = 
VAR GetTheAverageCreditUsed = AVERAGEX(SUMMARIZE('DateTable',DateTable[Date],"Day Total",SUM(Credits[Credits])),[Day Total])
VAR GetTheTotalCreditUsed = SUMX(SUMMARIZE('DateTable',DateTable[Date],"Day Total",SUM(Credits[Credits])),[Day Total])
VAR AddTheMeasures = GetTheAverageCreditUsed+GetTheTotalCreditUsed
VAR findTheDifference = 30 - AddTheMeasures
VAR findtheMaxDate = MAX('DateTable'[Date])
VAR settheExpDate = findtheMaxDate+findTheDifference

RETURN settheExpDate

BrianConnelly_0-1676920065843.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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