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

How to DAX a cumulative calculation when addiig or deleting (with condition)?

I have already done a normal cumulative report with this DAX 

Cumulative Licwnse = CALCULATE (COUNTA ( 'Cumulative'[Username] ),
FILTER (ALL ( 'Calendar'[Date] ),'Calendar'[Date] <= MAX ( 'Calendar'[Date] )))

 

Let get started on my logic.

Now, my new requirement is to add the new condition to update them. By the way, my logic is when I put the data in delete field that means this user is no longer anymore so next year the graph will be decreased. But if I don't put any data in the delete column that means this user continues using next year.

 

I have this sample data.

 

UsernameCreation date DeleteDepart.
as0112/9/2016 Accountiant
as0212/9/201613/9/2017Accountiant
as0312/6/2017 Accountiant
cs0112/6/201713/9/2018Marketing
CS0213/6/2017 Marketing

 

The result from my logic is following below sample chart.

Untitled.jpg

 

Year201620172018
Username254

 

 

Could you please give me a DAX solution? 

 

Thank you all for answering.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @saranp780,

 

You need to have in your calculation a reference to the time frame and not only to the start time of the license.

 

Assuming that your calendar table is not related with your cumulative table.

 

Use the following measure:

Cumulative License =
VAR Selected_year =
    YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
    CALCULATE (
        COUNTA ( 'Cumulative'[Username] );
        FILTER (
            ALL ( CUMULATIVE[Creation date ] );
            YEAR ( CUMULATIVE[Creation date ] ) <= Selected_year
        );
        FILTER (
            ALL ( CUMULATIVE[Delete] );
            YEAR ( CUMULATIVE[Delete] ) >= Selected_year
                || CUMULATIVE[Delete] = BLANK ()
        )
    )

 

See result below:

 

cumu.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @saranp780,

 

You need to have in your calculation a reference to the time frame and not only to the start time of the license.

 

Assuming that your calendar table is not related with your cumulative table.

 

Use the following measure:

Cumulative License =
VAR Selected_year =
    YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
    CALCULATE (
        COUNTA ( 'Cumulative'[Username] );
        FILTER (
            ALL ( CUMULATIVE[Creation date ] );
            YEAR ( CUMULATIVE[Creation date ] ) <= Selected_year
        );
        FILTER (
            ALL ( CUMULATIVE[Delete] );
            YEAR ( CUMULATIVE[Delete] ) >= Selected_year
                || CUMULATIVE[Delete] = BLANK ()
        )
    )

 

See result below:

 

cumu.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.