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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
adeeln
Post Patron
Post Patron

You need help writing DAX.

I want to show "New Active Customers" according to the following screenshot.

Need help with writing measures for two visual objects.

First. In which "New Active Customers" shows from the Minimum MonthYear(In date table) to the Selected MonthYear from Slicer .
Second. And in the second Visual it shows the "New Active Clients" of the last 24 months.


Here is the link for the live dashboard according to which I want to show.
https://public.tableau.com/profile/lintao#!/vizhome/DigitalStrategyDashboard/ClientInsight
I have used the following measures.


For new active customers #
New active clients? 
var minSelectedDate to minx (ALLSELECTED (DimDate), DimDate [Date])
return
CALCULATE (
DISTINCTCOUNT (FactDigitalStrategy [ClientKey]),
FILTER (DimDate,
DimDate [Date]>? minSelectedDate
), USERELATIONSHIP (FactDigitalclientStrategy [new Date], Dim Date [DimDigitalStrategy] ))
For "The last 24 months new active customers"
New Active Customers (last 24 months) 
WHERE MaxFactDate?
CALCULATE (MAX (FactDigitalStrategy [Date]), ALL ('DimDate'))
VAR FDate (VAR FDate)
ENDOFMONTH ('DimDate' [Date])
VA Edate (VAR Edate)
EDATE (FDate, -24)
return
IF (
MaxFactDate < - MAX ('DimDate' [Date])
&& MaxFactDate> - Edate,
CALCULATE ([New active clients], ALL ('DimDate')) + 0
)
For Visual in which "New active customers" shows from the year of the minimum month to the year of the selected month.
Active Customers (last n months) below the next part of the page of the next part of the 
Was page MaxFactDate?
CALCULATE (MAX (FactDigitalStrategy [Date]), ALL ('DimDate'))
VAR FDate (VAR FDate)
ENDOFMONTH ('DimDate' [Date])
VA Edate (VAR Edate)
CALCULATE (MIN (DimDate [Date]), ALL ( 'DimDate'))
return
IF (
MaxFactDate <- MAX ('DimDate' [Date])
&& MaxFactDate> - Edate,
CALCULATE ([Active Clients], ALL ('DimDate'))
) + 0
Here is my Pbix file link.
https://www.dropbox.com/s/yapdk88x7duhuqa/Digital%20Strategy%20-%20Client%20Insight%20test.pbix?dl=0
1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@adeeln 

See if this works for you (apologies since I din't apply the colour coding you have in your original):

Result.JPG

 

1) To calculate the new clients by month:

New clients in month =
VAR PrevYM =
     ( MAX ( FactDigitalStrategy[Year] ) - 1 ) * 100
        + RIGHT ( SELECTEDVALUE ( FactDigitalStrategy[MonthYearNo] ), 2 )
VAR ActualClients =
    VALUES ( FactDigitalStrategy[ClientKey] )
VAR PrevYearMonthClients =
    CALCULATETABLE (
        VALUES ( FactDigitalStrategy[ClientKey] ),
        FILTER (
            ALL ( FactDigitalStrategy ),
            FactDigitalStrategy[MonthYearNo] = PrevYM
        )
    )
RETURN
    COUNTROWS ( EXCEPT ( ActualClients, PrevYearMonthClients ) )

2) To filter the visuals based on the selection in the slicers, I created a new disconnected table for the new and active clients (and used this table for the visuals)

3) To filter the visuals, I created a measure to use in the filters for the visuals in the filter pane:

New client table (Filtered) =
IF (
    SELECTEDVALUE ( '1 New client table'[MonthYearNbr] )
        <= SELECTEDVALUE ( DimDate[MonthYearNbr] ),
    1
)

  

Let us know if you need further help

I'm attachiing the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
PaulDBrown
Community Champion
Community Champion

@adeeln 

See if this works for you (apologies since I din't apply the colour coding you have in your original):

Result.JPG

 

1) To calculate the new clients by month:

New clients in month =
VAR PrevYM =
     ( MAX ( FactDigitalStrategy[Year] ) - 1 ) * 100
        + RIGHT ( SELECTEDVALUE ( FactDigitalStrategy[MonthYearNo] ), 2 )
VAR ActualClients =
    VALUES ( FactDigitalStrategy[ClientKey] )
VAR PrevYearMonthClients =
    CALCULATETABLE (
        VALUES ( FactDigitalStrategy[ClientKey] ),
        FILTER (
            ALL ( FactDigitalStrategy ),
            FactDigitalStrategy[MonthYearNo] = PrevYM
        )
    )
RETURN
    COUNTROWS ( EXCEPT ( ActualClients, PrevYearMonthClients ) )

2) To filter the visuals based on the selection in the slicers, I created a new disconnected table for the new and active clients (and used this table for the visuals)

3) To filter the visuals, I created a measure to use in the filters for the visuals in the filter pane:

New client table (Filtered) =
IF (
    SELECTEDVALUE ( '1 New client table'[MonthYearNbr] )
        <= SELECTEDVALUE ( DimDate[MonthYearNbr] ),
    1
)

  

Let us know if you need further help

I'm attachiing the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






adeeln
Post Patron
Post Patron

Please help to write a DAX.

PaulDBrown
Community Champion
Community Champion

@adeeln 

 

Sorry, I'm not understanding what you are trying to achieve with "New active clients". New compared to when?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown i need to show the "New active clients" from the minimum date(that present in fact or dimdate table) to Max Selected date from Month or year Slicer.

For better understanding, this is the link for the live dashboard according to which I want to show.
https://public.tableau.com/profile/lintao#!/vizhome/DigitalStrategyDashboard/ClientInsight

@adeeln 

 

Sorry if I'm being dense, but normally when one says "New active clients", the idea is that these are clients which are active (in the period) but were not active in another period. For example, new active clients this year vs last year (which would be clients which were not active last year).

You mention a period, but not when you consider a client to be "New" (compared to the previous month? previous year...?)

If however you are looking for clients which are active, you can use DISTINCTCOUNT





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown In my report, I have 2 types of KPI according to Client . one is "Active Clients #" and this is the distinctcount of ClientKey.
And second is "New Active Clients #" and this is New Clients.
Need to help me to calculate the "New Active Clients #" measure.
And show this "New Active Clients #" according to the live dashboard. The live dashboard link is here

https://public.tableau.com/profile/lintao#!/vizhome/DigitalStrategyDashboard/ClientInsight.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.