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

Create Table with distinct values and count them

Hello,

I've started working with Power BI desktop, and trying to count how many items I have in a period(it's dynamic)

This is my source table product A:

Serial#Manufacturing  dateSale Date
278279/1/202010/8/2020
266459/23/201910/8/2020
2507610/28/20185/6/2016
747711/3/20105/6/2016
174843/2/20154/7/2015
285351/17/20211/23/2021

I'm thinking of creating another table that contains a unique sales date table with distinct sale dates (I've managed to do that)

but now I need to count how many items were sold for each sale date, and here couldn't find a solution.

The result table will look like this:

Sale Date# Of items sold
10/8/20202
 5/6/20162
4/7/20151
1/23/20211

 

your help will be much appreciated.

 

1 ACCEPTED SOLUTION

Create an inactive relationship from your Date table to the Sale Date column and then you can use USERELATIONSHIP, like

Num sales = CALCULATE( COUNTROWS('Table'), USERELATIONSHIP( 'Date'[Date], 'Table'[Sale date]))

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Create a proper Date table, and link the Date column to the Sale Date column in your current table. You can then use columns from the Date table in any visuals and create a measure like COUNTROWS('Products')

Anonymous
Not applicable

Thanks johnt75, I've created a proper calendar table, and already have a relationship with my product A table (to the manufacturing date), and whenever I try to work with standard measures it doesn't count the relevant rows.

i'm trying to get to some sort of a formula similar to count if Date=Sale Date   

Create an inactive relationship from your Date table to the Sale Date column and then you can use USERELATIONSHIP, like

Num sales = CALCULATE( COUNTROWS('Table'), USERELATIONSHIP( 'Date'[Date], 'Table'[Sale date]))

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.