Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Calculating a rolling difference over integer categories

Dear PowerBI Community,

 

I am having trouble with a seemingly easy task: I need to calculate a percentage of the customers lost after each sales step. Each solution I could find referred to a date, however, in my case I have no date at all.

 

Here you see a simple unique count of the customer IDs that were completed in a respective sales step:PowerBI_Q.JPG

 

 

 

 

 

 

 

 

 

 

 

 

Now I need to calculate a difference in the count of unique values between two numeric integer categories (that are always increasing and never miss a number). I.e. the values by each category presented above would look like 0% - 33% - 0% - 50% - 66%.

Link to a file on drive does not seem to work, so I attach the screenshots of the tables to demonstrate the underlying data (really sorry for the inconvenience):

 

PowerBI_Q3.JPGPowerBI_Q2.JPG

 

PowerBI_Q5.JPG

 

PowerBI_Q4.JPG

 

 

I have tried a couple of measures but failed miserably.

 

I would highly appreciate you help and guidance on this one! 

 

Best,

Andrei

 

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

That's page 198 of my book, Crafting a funnel drop-off rate, it goes something along the lines of:

 

Drop Off Rate = 
    VAR __CurrentStep = MAX([Step])
    VAR __PreviousStep = __CurrentStep - 1
    VAR __CurrentCount = COUNTROWS('R01_Table')
    VAR __PreviousCount = 
        IF(
            __CurrentStep = 1 , 
            0 , 
            COUNTROWS(FILTER(ALL('R01_Table'),[Step] = __PreviousStep ))
        )
RETURN
    DIVIDE(__CurrentCount - __PreviousCount, __PreviousCount, 0)

 

There is also Abandoment Rate:

Abandonment Rate = 
    VAR __CurrentStep = MAX([Step])
    VAR __PreviousStep = 1
    VAR __CurrentCount = COUNTROWS('R01_Table')
    VAR __PreviousCount = 
        COUNTROWS(FILTER(ALL('R01_Table'),[Step] = __PreviousStep ))
RETURN
    DIVIDE(__CurrentCount - __PreviousCount, __PreviousCount, 0)

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You wanna calculate the differences in steps,right?

Then use below dax expression to create a measure:

 

Measure = 
var a =CALCULATE(MAX('Table'[Unique customers]),FILTER(ALL('Table'),'Table'[step number ]=MAX('Table'[step number ])-1))
Return
DIVIDE(MAX('Table'[Unique customers])-a,a)+0

 

And you will see:

Annotation 2020-04-21 125437.png

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You wanna calculate the differences in steps,right?

Then use below dax expression to create a measure:

 

Measure = 
var a =CALCULATE(MAX('Table'[Unique customers]),FILTER(ALL('Table'),'Table'[step number ]=MAX('Table'[step number ])-1))
Return
DIVIDE(MAX('Table'[Unique customers])-a,a)+0

 

And you will see:

Annotation 2020-04-21 125437.png

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Anonymous
Not applicable

Hey Kelly,

 

thank you for the swift reply - will try it and come back with feedback asap!

 

Best,

Andrei

Anonymous
Not applicable

Greg and Kelly,

 

thank you very much! The suggested measures worked perfectly! 

Have also learned from the suggestions!

 

Best,

Andrei

Greg_Deckler
Community Champion
Community Champion

That's page 198 of my book, Crafting a funnel drop-off rate, it goes something along the lines of:

 

Drop Off Rate = 
    VAR __CurrentStep = MAX([Step])
    VAR __PreviousStep = __CurrentStep - 1
    VAR __CurrentCount = COUNTROWS('R01_Table')
    VAR __PreviousCount = 
        IF(
            __CurrentStep = 1 , 
            0 , 
            COUNTROWS(FILTER(ALL('R01_Table'),[Step] = __PreviousStep ))
        )
RETURN
    DIVIDE(__CurrentCount - __PreviousCount, __PreviousCount, 0)

 

There is also Abandoment Rate:

Abandonment Rate = 
    VAR __CurrentStep = MAX([Step])
    VAR __PreviousStep = 1
    VAR __CurrentCount = COUNTROWS('R01_Table')
    VAR __PreviousCount = 
        COUNTROWS(FILTER(ALL('R01_Table'),[Step] = __PreviousStep ))
RETURN
    DIVIDE(__CurrentCount - __PreviousCount, __PreviousCount, 0)

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.