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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
pbrainard
Helper III
Helper III

Unique Clients per Quarter

I have a table of clients seen, broken down by quarter. As you can see the Total is unique clients but the quarters reflect unique clients in those quarters. The numbers are a distinct count of client IDs. I only want unique visitors if they weren't seen in a previous quarter. I've got the service date connected to a calendar table. I've got a slicer for the quarters.

 

pbrainard_0-1654699501521.png

 

1 ACCEPTED SOLUTION

You can use this code:

 

Count =
VAR _PrevQuarter =
    CALCULATETABLE (
        VALUES ( Table[ClientID] ),
        DATEADD ( 'Calendar Table'[Date], -1, QUARTER )
    )
VAR _CurrentQuarter =
    VALUES ( Table[ClientID] )
RETURN
    IF (
        ISINSCOPE ( 'Calendar Table'[Quarter] ),
        COUNTROWS ( EXCEPT ( _CurrentQuarter, _PrevQuarter ) ),
        DISTINCTCOUNT ( Table[ClientID] )
    )

 

This will provide the difference in quarters for the Quarter filter context (including the totals) and the total distincount per pooled cities on the row level and grand total. It might be worth providing an explanation to avoid false assumptions, or simply leave out the row totals altogether





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

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

I depends how the visual is structured (dimension fields or fields from fact table)

You will need semething alon the lines of:

 

 

Count =
VAR _PrevQuarter =
    CALCULATETABLE (
        VALUES ( Table[ClientID] ),
        DATEADD ( 'Calendar Table'[Date], -1, QUARTER )
    )
VAR _CurrentQuarter =
    VALUES ( Table[ClientID] )
VAR _Calc =
    COUNTROWS ( EXCEPT ( _CurrentQuarter, _PrevQuarter ) )
RETURN
    SUMX (
        SUMMARIZE (
            Table,
            Table[Pooled cities],
            'Calendar Table'[Quarter],
            "_Count", _Calc
        ),
        [_Count]
    )

 

Bear in mind this will just sum the values (ie the result will not be a DISTINCTCOUNT, but the sum of the distinctcounts, which I'm not sure makes any sense...)

 





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.






Yeah, you're right, doesn't make sense. Is there a way to incorporatethe year into the original code you shared, so it only counts IDs in the year selected in another slicer?

You can use this code:

 

Count =
VAR _PrevQuarter =
    CALCULATETABLE (
        VALUES ( Table[ClientID] ),
        DATEADD ( 'Calendar Table'[Date], -1, QUARTER )
    )
VAR _CurrentQuarter =
    VALUES ( Table[ClientID] )
RETURN
    IF (
        ISINSCOPE ( 'Calendar Table'[Quarter] ),
        COUNTROWS ( EXCEPT ( _CurrentQuarter, _PrevQuarter ) ),
        DISTINCTCOUNT ( Table[ClientID] )
    )

 

This will provide the difference in quarters for the Quarter filter context (including the totals) and the total distincount per pooled cities on the row level and grand total. It might be worth providing an explanation to avoid false assumptions, or simply leave out the row totals altogether





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
Community Champion
Community Champion

Try:

Count =
VAR _PrevQuarter =
    CALCULATETABLE (
        VALUES ( Table[ClientID] ),
        DATEADD ( 'Calendar Table'[Date], -1, QUARTER )
    )
VAR _CurrentQuarter =
    VALUES ( Table[ClientID] )
RETURN
    COUNTROWS ( EXCEPT ( _CurrentQuarter, _PrevQuarter ) )




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.






Looks to be working great for the quarters. Thank you!!! How can I get the total to aggregate across the quarters?

pbrainard_0-1654703459597.png

 

Helpful resources

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

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.