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

How to calculate active customers current and previous month by customer code

Good day.

 

ROA=running of account

I wanted to get the previous month active customer by using:

Previous Month ROA = CALCULATE (DISTINCTCOUNT('Running of Account'[Debtor Code]), PREVIOUSMONTH('Running of Account'[Date]))

But i got no value.

 

For current month ROA I'm using:

Current Month ROA =
CALCULATE ( DISTINCTCOUNT('Running of Account'[Debtor Code]),
    YEAR( 'Calendar'[Date]) = YEAR(MAX('Calendar'[Year Month])),
    MONTH( 'Calendar'[Date]) = MONTH(MAX('Calendar'[Year Month])))
 
And for current month is fine.
 
May I know where I have do it wrong?
 
Below are my example data.
 
Calendar table
ommfin123_0-1687331702000.png

 

Running of account data:

ommfin123_1-1687331766699.png

 

 

Thank you so much.

1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @ommfin123 in general CALCULATE could accept many filter arguments.

In your part Name],), this red comma is extra?

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





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

Proud to be a Super User!






View solution in original post

5 REPLIES 5
some_bih
Super User
Super User

Hi @ommfin123 in general CALCULATE could accept many filter arguments.

In your part Name],), this red comma is extra?

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





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

Proud to be a Super User!






Dear @some_bih ,

The red comma removed. But it's said my syntax for PREVIOUSMONTH is incorrect.

Very greatful for your kindness.

Hi @ommfin123 if it was ok return it, sorry.





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

Proud to be a Super User!






some_bih
Super User
Super User

Hi @ommfin123  DAX function PREVIOUSMONTH is one of the time intelligence functions in DAX, which works the best when applied on Date / Calendar table.

Try to change your part PREVIOUSMONTH('Running of Account'[Date])) to your Date table accordingly and check results. Hope this help





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

Proud to be a Super User!






Hi @some_bih ! Yeah! It's works! But I have a question too, I have repeated customers names with different customers' code, how can I add AND function to filter 2 conditions in this case? 

Previous Month ROA = CALCULATE(
FILTER(
    DISTINCTCOUNT('Running of Account'[Debtor Code],
    DISTINCTCOUNT('Running of Account'[Debtor Name],)
    PREVIOUSMONTH('Calendar'[Date])))

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.