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
Birinder
Helper III
Helper III

Reverse Cumulative sum but as a calculated column

Hi Community.

I am having trouble in creating a calculated column for reverse cumulative sum for one of my table.
I am using the measure but It doesn't seem much flexible.
Here is the measure, I am using:-

Measure Date = calculate(SUM('Full BECF'[USD]),FILTER(ALLSELECTED('Full BECF'[Date]),'Full BECF'[Date]>=selectedvalue('Full BECF'[Date])))

 

It is working fine as expected.
Below is a screenshot of the sample data

Birinder_0-1684393761930.png


Can I get the exact same values but as the calculated column.
Thanks a lot for the help in Advance.
Peace.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

If there is only one table, and you want a calculated column, you can just add the filters for other columns also...

 

ReverseCumulativeSum = 
SUMX(
    FILTER(
        ALL('Full BECF'),
        'Full BECF'[Date] >= EARLIER('Full BECF'[Date] &&
        'Full BECF'[Key] = EARLIER('Full BECF'[Key] &&
        'Full BECF'[Stage] = EARLIER('Full BECF'[Stage] &&
        'Full BECF'[Source] = EARLIER('Full BECF'[Source]
    ),
    'Full BECF'[USD]
)

 

 

View solution in original post

7 REPLIES 7
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1684399511869.png

 

 

Expected result CC =
SUMX (
    WINDOW (
        1,
        ABS,
        0,
        REL,
        SUMMARIZE ( 'Full BECF', 'Full BECF'[Date], 'Full BECF'[USD] ),
        ORDERBY ( 'Full BECF'[Date], DESC )
    ),
    'Full BECF'[USD]
)

 

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@JihwanKim 
Many thanks for the reply.
Unfortunately, WINDOWS function is not working for me.
It's not like the results are not coming as I want, It's that DAX is not recognizing it as function.

Anonymous
Not applicable

Try this:

 

 

ReverseCumulativeSum = 
SUMX(
    FILTER(
        ALL('Full BECF'),
        'Full BECF'[Date] >= EARLIER('Full BECF'[Date]
    ),
    'Full BECF'[USD]
)

If you don't want to use "EARLIER", you could store the date on a variable and then use it. For simiplicity, I avoided using variables and return statements.

 

Hi @Anonymous 

Thanks for the reply.
I am using it and it is working fine when we have only two rows i.e. date and amount.
I am trying to add extra row and then results are going crazy.

Birinder_0-1684403367345.png

AS you can see that total of USD is appearing as first value for the calculated column.
I guess it is calculating it on the basis of date only.
Is there a way by I can add one or more than one extra row alongwith date column and it gives me the values as per the extra column and also on the basis of date.
If it is sounding confusing here is the example generated from the same measure.

Birinder_1-1684403615337.png

Many thanks in Advance for help.

Anonymous
Not applicable

😀You should see this post 

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447595#M6071...

You should always give complete information. In your post, you said the data model has two columns and you wanted a calculated column. I gave the DAX for that.

 

Please post what are the tables, fileds and relationships between them and what exactly is the calculation that you need. Is it a measure that you want to use it in visuals or a calculated column on a table? Otherwise you will end up with getting incorrect DAX codes from the forum. Not only me, anyone who wants to help need all these information.

Hi @Anonymous 
Thanks for your reply.
I apologize but Its not that I am blaming you for this.
I actually needed DAX for two rows only.
Upon further granular analysis, I thought of using the other row too.

Anyway.
I will try to provide the full information.
There is only one table named as " Full BECF".
No relationship as there is only one table.
5 column in the table.

  • Source -  Used as a filter.
  • Stage - Used as a filter
  • Key- Used a 1st place in row section
  • Date - Used as 2nd place in row section 
  • USD - Used as value

I want the results as a calculated column.

Now I will try to explain you what I need.

I want reverse cumulative sum for the key column based on the Date column.
Just like the Screenshot below:

Birinder_0-1684406370794.png

Thanks for the help so far,

Anonymous
Not applicable

If there is only one table, and you want a calculated column, you can just add the filters for other columns also...

 

ReverseCumulativeSum = 
SUMX(
    FILTER(
        ALL('Full BECF'),
        'Full BECF'[Date] >= EARLIER('Full BECF'[Date] &&
        'Full BECF'[Key] = EARLIER('Full BECF'[Key] &&
        'Full BECF'[Stage] = EARLIER('Full BECF'[Stage] &&
        'Full BECF'[Source] = EARLIER('Full BECF'[Source]
    ),
    'Full BECF'[USD]
)

 

 

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.