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
ferbypbi
Frequent Visitor

[MEASURE] Cumulative / Target Indicator

guys, I am working on this example below:

Target:10 
   
 SalesCumulative
01/01/202111
02/01/202134
03/01/202148
04/01/2021513
   
Days untill reach target:4 

 

I created the cumulative sum:
Calculate( 
   Sum( table[column]),
       Filter(
           All(DateDim),
              DateDim[Date] <= Max(DateDim[Date])

its working!

But when I trying to create the indicator to see how many days until reach the target I am totally lost.

 

Target is sum of a table´s column.

Does anyone know how to start? I am stuck on this..

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

Hi @ferbypbi ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below to get the culmulative value

Cumulative = 
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "@cumulative",
            CALCULATE (
                SUM ( 'Table'[Sales] ),
                FILTER ( ALL ( 'Table' ), 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
            )
    )
RETURN
    SUMX ( _tab, [@cumulative] )

2. Create a measure as below to get the number of days which achive the target

The number of days which reach the target = 
VAR _target = 10
VAR _mindate =
    MINX ( ALL ( 'Table' ), 'Table'[Date] )
VAR _tdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( ALLSELECTED ( 'Table' ), [Cumulative] > _target )
    )
RETURN
    IF (
        _mindate = _tdate,
        1,
        IF ( _mindate < _tdate, DATEDIFF ( _mindate, _tdate, DAY ) + 1 )
    )

yingyinr_1-1637222946050.png

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @ferbypbi ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below to get the culmulative value

Cumulative = 
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "@cumulative",
            CALCULATE (
                SUM ( 'Table'[Sales] ),
                FILTER ( ALL ( 'Table' ), 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
            )
    )
RETURN
    SUMX ( _tab, [@cumulative] )

2. Create a measure as below to get the number of days which achive the target

The number of days which reach the target = 
VAR _target = 10
VAR _mindate =
    MINX ( ALL ( 'Table' ), 'Table'[Date] )
VAR _tdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( ALLSELECTED ( 'Table' ), [Cumulative] > _target )
    )
RETURN
    IF (
        _mindate = _tdate,
        1,
        IF ( _mindate < _tdate, DATEDIFF ( _mindate, _tdate, DAY ) + 1 )
    )

yingyinr_1-1637222946050.png

Best Regards

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

Hi @ferbypbi 

 

How did you calculate Days untill reach target: 4??  Can you add more details re the calculation?

 


Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

hello VahidDM,

 

Basically if the cumulative sum passes the target and from the beginning how many days have passed

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.