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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Distinct Count of weeks based on sales measure

I have to tables sale table and calendar table In calendar table I have weeks column. I have a calculation of sales in my sales table I want to get the number of weeks based on my sales measure.
I don't want all number of weeks but only the number of weeks where sales have been made according to my calculated sales measure.
Thanks.
week no.png

 

sale measure.png

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

The trick is to iterate the Sales table and count the number of weeks.  We can use SUMMARIZE to do that as it can access the extended table.

week count = 
COUNTROWS(SUMMARIZE('Sales','Date'[Week]))

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

@PaulOlding it worked just added a filter where payment=sales
thanks a lot!

 

PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

The trick is to iterate the Sales table and count the number of weeks.  We can use SUMMARIZE to do that as it can access the extended table.

week count = 
COUNTROWS(SUMMARIZE('Sales','Date'[Week]))
Anonymous
Not applicable

@PaulOlding  Thanks for your reply
The thing is that sales is not a column its a calculated measure

 

@Anonymous The 'Sales' referenced in my measure is the name of the table with all the sales amounts (ie the fact table)

Anonymous
Not applicable

@PaulOlding  this does not work can we try some other logic?

 

@Anonymous In that case some more information would be helpful.  See this post https://community.powerbi.com/t5/DAX-Commands-and-Tips/How-to-Get-Your-Question-Answered-Quickly/m-p/1626726#M32906 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors