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
MrDarian
Helper II
Helper II

"Change cumulative to periodic values

"Change cumulative to periodic values

Hello

in power bi  I have a table that is cumuative, so i want to write a measure to change it to periodical value. i want to have last column ( Yellow Column)"

@amitchandak

 

Capture.PNG

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

Hi, @MrDarian 

 

Based on your description, I created data to reproduce your scenario. The sample pbix file is attachded in the end.

Table:

c1.png

 

You may create a calculated column or a measure as below.

Periodic Amount Column = 
var _lastamount = 
CALCULATE(
    SUM('Table'[Cumnlative Amount]),
    FILTER(
        ALL('Table'),
        'Table'[Title ID] = EARLIER('Table'[Title ID])&&
        'Table'[Month ID] = EARLIER('Table'[Month ID])&&
        'Table'[Week ID] = EARLIER('Table'[Week ID])-1
    )
)
return
IF(
    ISBLANK(_lastamount),
    'Table'[Cumnlative Amount],
    'Table'[Cumnlative Amount]-_lastamount
)

Periodic Amount Measure = 
var _lastamount = 
CALCULATE(
    SUM('Table'[Cumnlative Amount]),
    FILTER(
        ALL('Table'),
        'Table'[Title ID] = SELECTEDVALUE('Table'[Title ID])&&
        'Table'[Month ID] = SELECTEDVALUE('Table'[Month ID])&&
        'Table'[Week ID] = SELECTEDVALUE('Table'[Week ID])-1
    )
)
return
IF(
    ISBLANK(_lastamount),
    SELECTEDVALUE('Table'[Cumnlative Amount]),
    SELECTEDVALUE('Table'[Cumnlative Amount])-_lastamount
)

 

Result:

c2.png

 

Best Regards

Allan

 

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

9 REPLIES 9
v-alq-msft
Community Support
Community Support

Hi, @MrDarian 

 

Based on your description, I created data to reproduce your scenario. The sample pbix file is attachded in the end.

Table:

c1.png

 

You may create a calculated column or a measure as below.

Periodic Amount Column = 
var _lastamount = 
CALCULATE(
    SUM('Table'[Cumnlative Amount]),
    FILTER(
        ALL('Table'),
        'Table'[Title ID] = EARLIER('Table'[Title ID])&&
        'Table'[Month ID] = EARLIER('Table'[Month ID])&&
        'Table'[Week ID] = EARLIER('Table'[Week ID])-1
    )
)
return
IF(
    ISBLANK(_lastamount),
    'Table'[Cumnlative Amount],
    'Table'[Cumnlative Amount]-_lastamount
)

Periodic Amount Measure = 
var _lastamount = 
CALCULATE(
    SUM('Table'[Cumnlative Amount]),
    FILTER(
        ALL('Table'),
        'Table'[Title ID] = SELECTEDVALUE('Table'[Title ID])&&
        'Table'[Month ID] = SELECTEDVALUE('Table'[Month ID])&&
        'Table'[Week ID] = SELECTEDVALUE('Table'[Week ID])-1
    )
)
return
IF(
    ISBLANK(_lastamount),
    SELECTEDVALUE('Table'[Cumnlative Amount]),
    SELECTEDVALUE('Table'[Cumnlative Amount])-_lastamount
)

 

Result:

c2.png

 

Best Regards

Allan

 

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

hello, thanks for your response, is it possible to do in my real data in the link below?

https://gofile.io/d/YmMgs2 

amitchandak
Super User
Super User

@MrDarian , Create a new column as

period Amount =		
table[cumulative Amount]  - maxx(filter(table, table[title ID] = earlier(table[title ID]) 	&& table[cumulative Amount] < earlier(table[cumulative Amount] )),table[cumulative Amount] )

this is my power bi file link download

 

https://gofile.io/d/YmMgs2 

it does'nt work

 

My DAX Formula:

period Amount =
'Weekly Performance'[SPerformanceAmount]
    - MAXX (
        FILTER (
            'Weekly Performance',
            'Weekly Performance'[SRefActionId]
                = EARLIER ( 'Weekly Performance'[SRefActionId] )
                && 'Weekly Performance'[SPerformanceAmount]
                    < EARLIER ( 'Weekly Performance'[SPerformanceAmount] )
        ),
        'Weekly Performance'[SPerformanceAmount]
    )
    
    

 

Capture.PNG

 

Capture1.PNG

@MrDarian or use following DAX expression to create a Columnchange Table and Column names as per your model:

 

Periodic Value = 
VAR __currValue = **bleep**[Column1]
VAR __prevValue = 
    CALCULATE ( 
        MAX ( **bleep**[Column1] ), 
        ALLEXCEPT ( **bleep**, **bleep**[Id] ), 
        **bleep**[Column1] < __currValue 
    ) 
RETURN __currValue - __prevValue

 

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



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.

It does'nt work

 

My DAX for Column:

Periodic Value =
VAR __currValue = 'Weekly Performance'[SPerformanceAmount]
VAR __prevValue =
CALCULATE (
MAX ('Weekly Performance'[SPerformanceAmount] ),
ALLEXCEPT ( 'Weekly Performance', 'Weekly Performance'[Id] ),
'Weekly Performance'[SPerformanceAmount] < __currValue
)
RETURN __currValue - __prevValue
 
 
Capture2.PNGCapture3.PNG

@MrDarian please share pbix file with sample data to further look into it. Remove any sensitive information before sharing.



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
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.