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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
streli
Helper I
Helper I

Power bi calculate sum taking into account the expiry date

Hi

 

I have a dataday and an expiry date column for a year, each dataday has an expiry date and a unit value.

How can I calculate a cumulative amount for the unit values, so that the calculation skips the datadays and unit values with an earlier expiry date than the dataday?

 

For example, there is an expiry date of 20 June for a 20 June dataday and therefore I don't want it to be included in the cumulative amount of 21 June.

 

Thank you very much!

 

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

Hi @streli ,

 

Please try:

Amount Cumulative = SUMX(FILTER(ALL(data),[DataDay]<=SELECTEDVALUE(data[DataDay])&&[ExpiryDay]>=SELECTEDVALUE(data[DataDay])),[Volumen])

Final output:

vjianbolimsft_0-1688022127833.png

Best Regards,

Jianbo Li

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

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @streli ,

 

Please try:

Amount Cumulative = SUMX(FILTER(ALL(data),[DataDay]<=SELECTEDVALUE(data[DataDay])&&[ExpiryDay]>=SELECTEDVALUE(data[DataDay])),[Volumen])

Final output:

vjianbolimsft_0-1688022127833.png

Best Regards,

Jianbo Li

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

Hi Jianbo Li, very good, thank you very much for you reply, it works!!!

Sahir_Maharaj
Super User
Super User

Hello @streli,

 

Can you please try: 

Cumulative Amount =
VAR CurrentDate = 'Table'[dataday]
RETURN
    CALCULATE(
        SUM('Table'[unit value]),
        'Table'[expiry date] >= CurrentDate
    )

Do not hesitate to let me know if you might need further assistance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

hello

thank you very much for your reply!

unfortunately after VAR it does not recognize the DataDay field in the data table

 

streli_0-1687616900493.png

 

do you have any more ideas?

thank you very much

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.