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
Anonymous
Not applicable

Counting Table rows in a relationship with another table, between dates!

Hi! I'm very much new to Power BI and I have issues all over haha, but I would love some guidance with this problem in particular!

I have three tables:

  1. A table with handheld devices (Used by users to create fines) - mobile_device
  2. A table with said fines given by said users -violation
  3. A table with the users - users

mobile_device and violation are both related by "hostname", a varchar, the unique name of the mobile_device

Each fine has a date/time value of the moment it was given.

I have created a table visualization by adding it mobile_device hostname, and violation id, and i made it show the total amount of violations per handheld device. I then added a splicer, putting in it the violation dates. This succesfully automatically filters the amount of violations given by each machine in the table, depending on the dates used on the filter!
Here's the issue, i would like to count the amount of machines that gave said fines in between the splicer dates and display it on a card, but when i place the hostname values on it, it only shows the total amount of machines without taking the fine dates into consideration. I wish i could count the amount of rows in the table visualization and be done with it, but it's in my understanding that you can't calculate based on visualizations.
I've tried using the Filter measure but PowerBI won't detect the relationships so the measure doesn't work...

Any guidance would be apreciated!
Tables

Tables!Tables!

Mobile Device Table
Mobile_deviceMobile_device

Violations Table

Violation (a)Violation (a)

Violation(b)Violation(b)

Visualization

VisualizationVisualization

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

According to your descriptions, it seems like a common date range analysis requirement.

If that is the case, I'd like to suggest you take a look at the following blog 'start date', 'end date' part if it suitable to your requirement:

Before You Post, Read This 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
selimovd
Super User
Super User

Hey @Anonymous ,

 

so the violation-table seems to be your fact table.

Why don't you count the IDs in the fact table. The following measure should give you the result:

Distinct Hostnames = DISTINCTCOUNT( violation[hostname] )

 

Like this you should get the distinct amount of different hostnames based on all filters.

If you count the amount of different hostnames in the mobile_device table it always shows the total as there won't apply any other filters.

Also think to create a proper data table, that will help you a lot when analyzing with time intelligence.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

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.