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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ngrulovic
Frequent Visitor

Forecast - Cumulative Totals taking the most recent month as benchmarking for coming period

Dear Friends,

I would very much appreciate it if you can help me with the following:

Namely I would like to make measure cumulative totals where for past months it will be used actuals and for the future months it would take the actual from the most recent month.

In the example below I have Jan 2022 as the most recent month, and I would like that this amount is used for future months for calculating cumulative. I have shared also the link of the file

 

https://drive.google.com/file/d/1EiT1PD8v3fLD5WMsALOXqsVheNIKGSDb/view?usp=sharing

 

 

ngrulovic_0-1644587952959.png

 

 

2 ACCEPTED SOLUTIONS

Hello 🙂

 

Thank you very much for offered solution. It is works partially.  There are still two problems that I see. First, you see that in 2021 you have cumulative values which are not correspondings to desired values as it is in column Value. Also when you add slicer and select some period witinin 2022 I get the wrong cumulative values. Please see the screen below

ngrulovic_0-1644956690069.png

 

View solution in original post

Hi @ngrulovic ,

 

I modify the measure, please try it.

 

Cumulative Sales = 
VAR maxDate =
    MAXX ( ALL ( Sales ), Sales[Dates] )
VAR factvalue =
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER ( ALLSELECTED ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
    )
VAR Predictedvalue =
    factvalue
        + DATEDIFF ( MAXX ( ALL ( Sales ), Sales[Dates] ), MAX ( Dates[Date] ), MONTH )
            * CALCULATE (
                SUM ( Sales[Value] ),
                FILTER ( ALL ( Sales ), Sales[Dates] = maxDate )
            )
RETURN
    IF (
        FORMAT ( MIN ( Dates[Period] ), "yyyymm" ) > FORMAT ( maxDate, "yyyymm" ),
        Predictedvalue,
        factvalue
    )

vkkfmsft_0-1644994623377.png           vkkfmsft_1-1644994683722.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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-kkf-msft
Community Support
Community Support

Hi @ngrulovic ,

 

Please try the following formula:

 

Cumulative Sales = 
VAR maxDate = MAXX ( ALLSELECTED ( Sales ), Sales[Dates] )
VAR factvalue =
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER ( ALL ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
    )
VAR Predictedvalue =
    factvalue
        + DATEDIFF (
            MAXX ( ALLSELECTED ( Sales ), Sales[Dates] ),
            MAX ( Dates[Date] ),
            MONTH
        )
            * CALCULATE (
                SUM ( Sales[Value] ),
                FILTER ( ALLSELECTED ( Sales ), Sales[Dates] = maxDate )
            )
RETURN
    Predictedvalue

vkkfmsft_0-1644916952118.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello 🙂

 

Thank you very much for offered solution. It is works partially.  There are still two problems that I see. First, you see that in 2021 you have cumulative values which are not correspondings to desired values as it is in column Value. Also when you add slicer and select some period witinin 2022 I get the wrong cumulative values. Please see the screen below

ngrulovic_0-1644956690069.png

 

Hi @ngrulovic ,

 

I modify the measure, please try it.

 

Cumulative Sales = 
VAR maxDate =
    MAXX ( ALL ( Sales ), Sales[Dates] )
VAR factvalue =
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER ( ALLSELECTED ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
    )
VAR Predictedvalue =
    factvalue
        + DATEDIFF ( MAXX ( ALL ( Sales ), Sales[Dates] ), MAX ( Dates[Date] ), MONTH )
            * CALCULATE (
                SUM ( Sales[Value] ),
                FILTER ( ALL ( Sales ), Sales[Dates] = maxDate )
            )
RETURN
    IF (
        FORMAT ( MIN ( Dates[Period] ), "yyyymm" ) > FORMAT ( maxDate, "yyyymm" ),
        Predictedvalue,
        factvalue
    )

vkkfmsft_0-1644994623377.png           vkkfmsft_1-1644994683722.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@ngrulovic check this video on my youtube channel https://youtu.be/9Mj592bSKq0

 

Tweak the solution as you see fit.

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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