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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Imex197
Helper I
Helper I

Recursive Calculation current Month different

Hello,

 

I need your help.

I want to calculate YTD "Won" Volume + expected Volume for next months until 12/20. But the current month should include Won Volume and the expected Volume.

 

 

My Dax Code for this measure is:

WonYTD and Expected CY = IF (
NOT ( ISBLANK ( [Estimated Opportunity Value ACD won] ) );
[Estimated Opportunity Value ACD won];
CALCULATE (
[Expected Prob Value ECD])
)

 

As visual I use the Waterfall:WaterFall.png

 

Thanks in advance.

Cheers

Imex197

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Imex197 

 

I have tried to make the below solution which I believe works just fine. I assume you have a calendar table which you should also use on the axis.

 

Measure = 
IF(
    -- VALUES(Calendar[Date]) returns all seletected days in a given context
    TODAY() in VALUES( 'Calendar'[Date]);
    SUM( 'Fact'[Expected]) + SUM( 'Fact'[Won]); -- current month
    IF(
        -- If today is larger than the largest date in the filter context then we are looking at previous months thus use [Won] else [Expected]
        TODAY() > MAXX( VALUES( 'Calendar'[Date]); [Date]); 
        SUM( 'Fact'[Won]);
        SUM( 'Fact'[Expected])
    )
)

 

If this works then please mark it as the accepted solution. Kudos is also appreciated.

 

BR

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

Not Sure I got it completely. Can you share sample data and sample output?

You can use time intelligence for YTD with date calendar

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Hi amitchandak,

 

thanks for your fast reply. I Can´t share any data.

let me try again:Table_Waterfall.png

Mariusz
Community Champion
Community Champion

Hi @Imex197 

 

Try something like below

 

Measure = 
VAR __dates = DATESYTD( 'Calendar'[Date] )
VAR __endOfMonth =  
CALCULATE(
    MAX( 'Calendar'[Date] ),
    FORMAT( 'Calendar'[Date], "YYYYMM" ) = FORMAT( TODAY(), "YYYYMM" )
)
VAR __before = CALCULATE(
    SUM( 'Table'[Value] ),
    FILTER( __dates, 'Calendar'[Date] <= __endOfMonth )
)
VAR __after = CALCULATE(
    SUM( 'Table'[Value] ),
    FILTER( __dates, 'Calendar'[Date] > __endOfMonth )
)
RETURN 
__before + __after

 

 

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Hi @Mariusz 

 

thanks for your help.

I changed the Format to "YYYYMMDD" now it suits better 🙂

But I wanted to have isolated values.

Is there a chance to have these value isolated per month and not cumulative?

 

Cheers

Imex197

 

Anonymous
Not applicable

Hi @Imex197 

 

I have tried to make the below solution which I believe works just fine. I assume you have a calendar table which you should also use on the axis.

 

Measure = 
IF(
    -- VALUES(Calendar[Date]) returns all seletected days in a given context
    TODAY() in VALUES( 'Calendar'[Date]);
    SUM( 'Fact'[Expected]) + SUM( 'Fact'[Won]); -- current month
    IF(
        -- If today is larger than the largest date in the filter context then we are looking at previous months thus use [Won] else [Expected]
        TODAY() > MAXX( VALUES( 'Calendar'[Date]); [Date]); 
        SUM( 'Fact'[Won]);
        SUM( 'Fact'[Expected])
    )
)

 

If this works then please mark it as the accepted solution. Kudos is also appreciated.

 

BR

Hi @Anonymous ,

 

this is perfect! Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.