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
warnera
Helper I
Helper I

calculate total (to date) of cumulative forecast total

Hello, I have a cumulative total from last year (2018 WAH RIDP) and data from this year (2019 YTD RIDP) graphed together. I would like to create a measure to show the difference between these two as of today. A simple difference between these two (2018-2019) includes the 2018 data for the entire year. How can I write a measure to only include current year on the last years accumulation...simply put based on my screenshot I need the following : 4550-4146 = 404. 2019-10-21 11_47_49-AST Micro Dashboard - Power BI Desktop.png

2018 WAH RIDP =
CALCULATE(RIDP[2019 RIDP Forecast],
FILTER(ALLSELECTED('Date Table'),
'Date Table'[Date]<=MAX('Date Table'[Date])))
 
2019 YTD RIDP =
IF(ISBLANK(RIDP[RIDP Total Tests]),
BLANK(),
CALCULATE(RIDP[RIDP Total Tests],
FILTER(ALLSELECTED('Date Table'),
'Date Table'[Date]<=MAX('Date Table'[Date])))
)

 

3 REPLIES 3
v-joesh-msft
Solution Sage
Solution Sage

Hi @warnera ,

You can try the following measure:

Measure =
VAR _maxprdpdate =
    CALCULATE ( MAX ( RIDP[Date] ), ALLSELECTED ( RIDP ) )
RETURN
    IF (
        _maxprdpdate = MAX ( 'Date Table'[Date] ),
        [2019 YTD RIDP] - [2018 WAH RIDP]
    )

If not your case, please share your sample pbix file if you don't have any Confidential Information.

Best Regards,

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

Can you clarify VAR_maxprdpdate?

 

That return if logic seems more like SQL?


@v-joesh-msft wrote:

Hi @warnera ,

You can try the following measure:

Measure =
VAR _maxprdpdate =
    CALCULATE ( MAX ( RIDP[Date] ), ALLSELECTED ( RIDP ) )
RETURN
    IF (
        _maxprdpdate = MAX ( 'Date Table'[Date] ),
        [2019 YTD RIDP] - [2018 WAH RIDP]
    )

If not your case, please share your sample pbix file if you don't have any Confidential Information.

Best Regards,

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


 

Hi @warnera ,

Variables are a major feature that makes writing DAX code easier. It stores the result of an expression as a named variable, which can then be passed as an argument to other measure expressions.

Here are some explanations of variables and some exceptions, you can take a look:

Variables in DAX

https://docs.microsoft.com/en-us/dax/var-dax

Best Regards,

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

 

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.