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

Incremental into cumulative

Hi

 

I have been trying solutions but i just don't get it

I want to do the following on Power BI

img3.png

 

Like a sum with condition on date and on the the same product x lob

I tried TotalYTD but it didn't work.

Does someone knows how to do it ?

 

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

Hi, @hidrag 

According to your description, I can roughly understand your requirement, you want to sum the "amount" if it's the same product and Lob for all valuation date anterior to the one in the line and create a slicer to filter the data based on the date column, right? I think you can create a measure to use the AllSelected() function instead of All() like this to achieve your requirement:

Cumulative Amount 1 =

CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),[LoB]=MAX('Table'[LoB])&&[Valuation Date]<=MAX('Table'[Valuation Date])))

And you can get what you want, like this:

vrobertqmsft_0-1635846577936.png

 

You can download my test pbix file below

For more info about the Allselected() function in DAX, please refer to this link:

https://docs.microsoft.com/en-us/dax/allselected-function-dax

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

5 REPLIES 5
v-robertq-msft
Community Support
Community Support

Hi, @hidrag 

According to your description, I can roughly understand your requirement, you want to sum the "amount" if it's the same product and Lob for all valuation date anterior to the one in the line and create a slicer to filter the data based on the date column, right? I think you can create a measure to use the AllSelected() function instead of All() like this to achieve your requirement:

Cumulative Amount 1 =

CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),[LoB]=MAX('Table'[LoB])&&[Valuation Date]<=MAX('Table'[Valuation Date])))

And you can get what you want, like this:

vrobertqmsft_0-1635846577936.png

 

You can download my test pbix file below

For more info about the Allselected() function in DAX, please refer to this link:

https://docs.microsoft.com/en-us/dax/allselected-function-dax

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

smpa01
Super User
Super User

@hidrag  you can use the following measure

 

Measure =
CALCULATE (
    SUM ( 'Table'[Amount] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Valuation Date] <= MAX ( 'Table'[Valuation Date] )
    ),
    KEEPFILTERS ( SUMMARIZE ( 'Table', 'Table'[Product], 'Table'[LoB] ) )
)

 

 

smpa01_0-1635795042552.png

 

If you need calculated column

cumulativeSum =
SUMX (
    FILTER (
        'Table',
        'Table'[Product] = EARLIER ( 'Table'[Product] )
            && 'Table'[LoB] = EARLIER ( 'Table'[LoB] )
            && 'Table'[Valuation Date] <= EARLIER ( 'Table'[Valuation Date] )
    ),
    'Table'[Amount]
)

 

smpa01_1-1635795292909.png

 

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
hidrag
Frequent Visitor

Thanks I'll have a look.

 

 

The data is below. The output is col "Cumulative Amount 1"

It sums "amount" if it's the same product and Lob for all valuation date anterior to the one in the line

 

ProductLoBValuation DateAmountAmount 2MonthCumulative Amount 1
AAccident01/01/202110100January10
AAccident01/02/202120200February30
AAccident01/03/202130300March60
AAccident01/04/202140400April100
AAccident01/05/202150500May150
AAccident01/06/202160600June210
AAccident01/07/202170700July280
AAccident01/08/202180800August360
AAccident01/09/202190900September450
AAccident01/10/20211001000October550
AMotor01/01/2021150250January150
AMotor01/02/2021200300February350
AMotor01/03/2021250350March600
AMotor01/04/2021300400April900
AMotor01/05/2021350450May1250
AMotor01/06/2021400500June1650
AMotor01/07/2021450550July2100
AMotor01/08/2021500600August2600
AMotor01/09/2021550650September3150
AMotor01/10/2021600700October3750
Greg_Deckler
Super User
Super User

@hidrag See if this helps: S Excel to DAX Translation - Microsoft Power BI Community

 

Otherwise, Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

OK so i found this

 

Cumulative Total =
CALCULATE (
SUM(Sheet1[Amount]),
FILTER (
ALL( Sheet1),
Sheet1[Valuation Date] <= EARLIEST ( Sheet1[Valuation Date])))
 
Which give me the cumulative sum by valuation date but i cannot add filter.
Can someone help

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.

Top Solution Authors