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

Calculating Gross Retention amount as a fixed value of another column

Hey guys,

Exploring DAX language and I am amazed so far. Most of the things I was able to get except for gross retention. I hope some of you know to get it. Need to get gross retention filtered by report dates in the pivot table.

These columns are my data set.

IndexAccount NameCustomerCustomer CohortReport DateEnding MRR

 


 I was able to get the net retained amount of customers who have signed before 12 months or more, but when I tried to do the same with the gross amount (if ending MRR before 12 months < ending MRR today THEN ending MRR today OTHERWISE ending MRR before 12 months) it worked good when I use "Customer" as rows. When I use "Report Dates" then the formula is applying on the sum of report dates.

I would need to have a fixed value of the sum of the customer gross retained amount but in a report date row.

 
Row LabelsSum of Ending MRR (current)Same Period Last Year MRR12 months net retained MRRGROSS RETAINED
4/30/201445692968.30973880.4182 
 
 
 
 

Is it possible to get it?

I would be so grateful ie of you can help.

Many thanks!

2 ACCEPTED SOLUTIONS
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i think its a measure total issue.

So i extract some sample data from your Excel to test:

2.PNG

Then create a measure as your logic:

Measure 1 = MIN(SUM('Table'[Same period last year]),SUM('Table'[Sum of Ending MRR]))

It shows the same issue as you posted:

3.PNG

Then try this measure:

Measure 2 = SUMX(GROUPBY('Table','Table'[Date],'Table'[Customer ID]),CALCULATE(MIN(SUM('Table'[Same period last year]),SUM('Table'[Sum of Ending MRR]))))

The result shows:

5.PNG

Try to create a calculated column to check:

Gross retained = MIN('Table'[Same period last year],'Table'[Sum of Ending MRR])

It shows the same with measure 2:

6.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

 

 

View solution in original post

Hi,

 

Please try this calculated column:

Same period last year MRR = 
VAR MinYearPerName =
    YEAR (
        CALCULATE (
            MIN ( 'Table'[Report Date] ),
            FILTER ( 'Table', 'Table'[Account Name] = EARLIER ( 'Table'[Account Name] ) )
        )
    )
VAR a = 'Table'[Report Date]
RETURN
    IF (
        YEAR ( 'Table'[Report Date] ) <> MinYearPerName,
        CALCULATE (
            MAX ( 'Table'[Ending MRR] ),
            FILTER (
                'Table',
                'Table'[Account Name] = EARLIER ( 'Table'[Account Name] )
                    && 'Table'[Report Date]
                        = DATE ( YEAR ( a ) - 1, MONTH ( a ) + 1, 1 ) - 1
            )
        ),
        BLANK ()
    )

The result shows:

23.PNG

 

Best Regards,

Giotto Zhi

View solution in original post

6 REPLIES 6
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i think its a measure total issue.

So i extract some sample data from your Excel to test:

2.PNG

Then create a measure as your logic:

Measure 1 = MIN(SUM('Table'[Same period last year]),SUM('Table'[Sum of Ending MRR]))

It shows the same issue as you posted:

3.PNG

Then try this measure:

Measure 2 = SUMX(GROUPBY('Table','Table'[Date],'Table'[Customer ID]),CALCULATE(MIN(SUM('Table'[Same period last year]),SUM('Table'[Sum of Ending MRR]))))

The result shows:

5.PNG

Try to create a calculated column to check:

Gross retained = MIN('Table'[Same period last year],'Table'[Sum of Ending MRR])

It shows the same with measure 2:

6.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

 

 

Hey, @v-gizhi-msft thank you very much for your response!!

Your solution is great! but there is only one small difference so I can't apply it - Same period last year is a measure in my model, but not calculated column - but you gave me a COOL idea, why shouldn't I created one column like this in big data set. But not sure how.

Can you please look at my data set: 

How could I get the desired Same period last year column (orange)? I tried with EARLIER and SAMEPERIODLASTYEAR but always stoped somewhere in the process.

Account NameEnding MRRReport DateSame period last year MRR
A507/31/2017 
A508/31/2017 
A589/30/2017 
A7010/31/2017 
A5011/30/2017 
A5012/31/2017 
A501/31/2018 
A502/28/2018 
A503/31/2018 
A504/30/2018 
A505/31/2018 
A1006/30/2018 
A1007/31/201850
A2008/31/201850
A2009/30/201858
A20010/31/201870
B2001/31/2019 
B2692/28/2019 
B2003/31/2019 
B2004/30/2019 
B2005/31/2019 
B2006/30/2019 
B2007/31/2019 
B2008/31/2019 
B2009/30/2019 
B20010/31/2019 
B5011/30/2019 
B5012/31/2019 
B501/31/2020200
B502/29/2020269


Many thanks once more!

Hi,

 

Please try this calculated column:

Same period last year MRR = 
VAR MinYearPerName =
    YEAR (
        CALCULATE (
            MIN ( 'Table'[Report Date] ),
            FILTER ( 'Table', 'Table'[Account Name] = EARLIER ( 'Table'[Account Name] ) )
        )
    )
VAR a = 'Table'[Report Date]
RETURN
    IF (
        YEAR ( 'Table'[Report Date] ) <> MinYearPerName,
        CALCULATE (
            MAX ( 'Table'[Ending MRR] ),
            FILTER (
                'Table',
                'Table'[Account Name] = EARLIER ( 'Table'[Account Name] )
                    && 'Table'[Report Date]
                        = DATE ( YEAR ( a ) - 1, MONTH ( a ) + 1, 1 ) - 1
            )
        ),
        BLANK ()
    )

The result shows:

23.PNG

 

Best Regards,

Giotto Zhi

Thank you very much @v-gizhi-msft ! Works PERFECTLY!

All the best from Croatia!

Thanks!

Greg_Deckler
Super User
Super User

It's a bit difficult to follow. 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

 

But, many times if you just want a fixed value for something you end up using ALL to ensure that you are not applying any filters. Or ALLEXCEPT if you want only some filters.


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

Hey @Greg_Deckler !

Thank you for the great post.

I am attaching the sample data that uses the real formulas. Attaching it in Excel Data model with DAX formulas becuase it is easier to visualize. If you can take a look I would be grateful.

https://mobilnainformatika-my.sharepoint.com/:x:/g/personal/tkozul_mobilnainformatika_onmicrosoft_co...

The explanation that I wrote before will have much more sense now.

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.