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
KMont
Regular Visitor

Grouping counts and distinct counts in DAX

I am trying to figure out a way to get the following table from my data...

 

I need repeat visitors to our platform.  I created a table that looks like this with a summary table, but can not link it to a time period.  Not sure if I need a DAX measure instead.  The number of accounts are those accounts that have 1 visits to our platform, 2 visits to our platform, 3 visits to our platform,etc during the time period specified in the filter on the page.  I can link the table that this graphic is based on to a network in the model, but can not link it to a date since I am trying to summarize it with counts.  I feel like there should be an easy way to accomplish this that I am missing.  Thanks in advance!

 

KMont_0-1748632787415.png

KMont

1 ACCEPTED SOLUTION

Hi @KMont,

 

Hi  

We wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.

If my answer resolved your query, please mark it as "Accept Answer" and give Kudos if it was helpful.

If you need any further assistance, feel free to reach out.

 

Thank you for being a valued member of the Microsoft Fabric Community Forum!

View solution in original post

9 REPLIES 9
v-sgandrathi
Community Support
Community Support

Hi @KMont,

 

Has your issue been resolved?If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.

 

Thank you for your understanding!

Hi @KMont,

  

We wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.

If my answer resolved your query, please mark it as "Accept Answer" and give Kudos if it was helpful.

If you need any further assistance, feel free to reach out.

Thank you for being a valued member of the Microsoft Fabric Community Forum!

Hi @KMont,

 

Hi  

We wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.

If my answer resolved your query, please mark it as "Accept Answer" and give Kudos if it was helpful.

If you need any further assistance, feel free to reach out.

 

Thank you for being a valued member of the Microsoft Fabric Community Forum!

I am so sorry for the delay.  I got side-tracked on other projects.  I tried it out and it worked!!  Thank you so much!  I am struggling a bit to get the table to sort since I am getting a circular reference error on the data table with the groups...1, 2, 3, 4, 5, 6, 7, >=8.  I added a sort column, but it is based on a dax calculation that created the first column.  Any ideas?

techies
Solution Sage
Solution Sage

Hi @KMont i don't know if you were able to download the pbix file, but here is the approach that i followed up

 

Created disconnected table like this

 

VisitGroup =
DATATABLE(
    "VisitGroup", STRING,
    {
        {"1"},
        {"2"},
        {"3"},
        {"4"},
        {"5"},
        {"6"},
        {"7"},
        {">=8"}
    }
)
 
And then the measure as this
 
AccountsByVisitGroup =
VAR GroupTable =
    ADDCOLUMNS (
        SUMMARIZE ( Visits, Visits[person_id] ),
        "VisitCount", CALCULATE ( COUNTROWS ( Visits ) )
    )

VAR SelectedGroup = SELECTEDVALUE ( VisitGroup[VisitGroup] )

RETURN
    SWITCH (
        TRUE(),
        SelectedGroup = "1", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 1 ) ),
        SelectedGroup = "2", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 2 ) ),
        SelectedGroup = "3", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 3 ) ),
        SelectedGroup = "4", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 4 ) ),
        SelectedGroup = "5", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 5 ) ),
        SelectedGroup = "6", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 6 ) ),
        SelectedGroup = "7", COUNTROWS ( FILTER ( GroupTable, [VisitCount] = 7 ) ),
        SelectedGroup = ">=8", COUNTROWS ( FILTER ( GroupTable, [VisitCount] >= 8 ) )
    )
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
techies
Solution Sage
Solution Sage

Hi @KMont please find the attached demo pix file here . Hope it is as required

 

demo-files/community question demo 1.pbix at master · cseprs/demo-files · GitHub

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
KMont
Regular Visitor

Here is a sample summary table..

 

person_idNetwork IdVisit IdDate
a4518/21/2024 0:00
a4528/22/2024 0:00
a4538/23/2024 0:00
a4548/24/2024 0:00
b4558/25/2024 0:00
c4568/26/2024 0:00
d4578/27/2024 0:00
d4588/28/2024 0:00
d4598/29/2024 0:00
d45108/30/2024 0:00
e45118/31/2024 0:00
e45129/1/2024 0:00
f45139/2/2024 0:00
f45149/3/2024 0:00
f45159/4/2024 0:00
f45169/5/2024 0:00
f45179/6/2024 0:00

 

Patient ID could be repeated, encounter id is unique to each row.  Want to count visits and the number of unique patients for each visit group...1 visit, 2 visits, 3 visits, etc.

KMont
Regular Visitor

I have an enounter table that lists all encounters and patient ids and network of each encounter as well as the date of each encounter.  I am trying to group by patient id to see how many encounters each patient has to show in this summary table.  The table needs to filtered by the network and time period selection.  I can provide a sample set if needed.

techies
Solution Sage
Solution Sage

Hi @KMont what does your model include?

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

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.