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

Reoccurring Distinct Counts

Hello,

 

I have a table that logs user activity across my dashboard that looks like this:

Mactoff_0-1677270081399.png

 

My stakeholder has requested to get a count of distinct users who have viewed the report in this quarter and the previous quarter. I am able to show this easily in a table by adding flags for if they viewed in this quarter and the previous quarter for the quarter that is selected, then writing a measure to check if they submitted in both. Example below:

Mactoff_1-1677270177185.png

 

 

However, the problem is I need to show this visual in a Card, not a table. In the example above my card would show the number 3, because there are only 3 users who have viewed the report in Q1 2023 and Q4 2022.

I tried doing a cumulative count for users <= the selected quarter, however this returns all distinct users who viewed in either quarter.

 

I also tried building a custom table with Summarize but there is no DistinctCountX function which throws a wrench in that plan.

 

DAX Samples:

RepeatUsers =
COUNTX(
FILTER (
SUMMARIZE (
'Report views',
'Report views'[User],
'Report views'[Quarter],
"Views", COUNT ( 'Report views'[UserID] )
),
[Views] > 0 && 'Report views'[Quarter] = SELECTEDVALUE(QuarterDim[Quarter])
),
'Report views'[User]
)

 


RepeatUsers =
VAR SelectedQuarter =
SELECTEDVALUE ( QuarterDim[Quarter] )
Var SelectedPriorQuarter=
SELECTEDVALUE(QuarterDim[PriorQuarter])
VAR Result =
CALCULATE (
DISTINCTCOUNT ( 'Report views'[UserId] ),
FILTER ( 'Report views', ('Report views'[Quarter] <= SelectedQuarter && 'Report views'[YearTerm] >= SelectedPriorQuarter )
)
RETURN
Result

 

Any help is greatly appreciated!

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create it based on what I have checked in the question above.

 

Jihwan_Kim_0-1677297294717.png

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create it based on what I have checked in the question above.

 

Jihwan_Kim_0-1677297294717.png

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Sorry for all the comments lol, I figured it out. It's because my Quarter filter is using the dimTable Quarter, not the 'Report views' table Quarter I just needed to create a relationship between the two tables. Thanks again!

Yea I'm not sure. I generated the extra rows and I still just get "blank" in my card. The measure works fine when I make a table visual and implement User as a row.

Yea I believe this isn't working for me because my source table doesn't actually have a recorded row for a Quarter in which they did not view the report, it only has records for when they did view the report. So essentially my sample table above would only have the rows where ViewedReport = 1. I think if I can generate rows for Quarters they did not view this solution should work.

I am reviewing now. I was unable to make it work on my first pass but that doesn't mean it doesn't work. Appreciate you putting this together. I'll get back to you later this afternoon.

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.