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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Jonathan_P
Helper II
Helper II

Sliced per day, count rows for the corresponding week and month

Hello,

 

The user wants a report where he will be able to select a day (slice per day). Then, on a matrix, he wants to see the number/count (measure) of analysis result (fact). He also wants to see it for the corresponding week and month for him to compare. By example, if he selects the date 2017-03-29, he wants to see the data for that day, for the week of 2017-03-26 and for the month of March 2017.

 

How do I write the measures?

 

Of course, it involves COUNTROWS. But, I have hard time figuring out the filters to pass to CALCULATE.

 

Thanks

1 ACCEPTED SOLUTION

@mattbrice,

 

By profiling the queries to SQL Server, I found that a part was missing in the measures Week Measure and Month Measure.

 

My measures are as follow:

 

 

 

Week Measure = CALCULATE ( [Count Analysis Result], FILTER ( ALL(Calendar), Calendar[Week Number] = MAX( Calendar[Week Number] ) ), FILTER ( ALL(Calendar), Calendar[Year] = MAX( Calendar[Year] ) ) )

 

Month Measure = CALCULATE ( [Count Analysis Result], FILTER ( ALL(Calendar), Calendar[Month Number] = MAX( Calendar[Month Number] ) ), FILTER ( ALL(Calendar), Calendar[Year] = MAX( Calendar[Year] ) ) )

View solution in original post

5 REPLIES 5
mattbrice
Solution Sage
Solution Sage

If you have  a best practice calendar table, just 3 simple mesaures should do it:. First is when slicer filters down to a day

 

Count Analysis Result = DISTINCTCOUNT ( Table[Analysis Result] )  (you can change this to COUNTROWS, COUNT, etc depending on need)

 

Week Measure = CALCULATE ( [Count Analysis Result], FILTER ( ALL(Calendar), Calendar[Week Number] = MAX( Calendar[Week Number] ) ) )   (You'll need a "Week Number" column added to Calendar table)

 

Month Measure = CALCULATE ( [Count Analysis Result], FILTER ( ALL(Calendar), Calendar[Month Number] = MAX( Calendar[Month Number] ) ) ) 

 

@mattbrice,

 

By profiling the queries to SQL Server, I found that a part was missing in the measures Week Measure and Month Measure.

 

My measures are as follow:

 

 

 

Week Measure = CALCULATE ( [Count Analysis Result], FILTER ( ALL(Calendar), Calendar[Week Number] = MAX( Calendar[Week Number] ) ), FILTER ( ALL(Calendar), Calendar[Year] = MAX( Calendar[Year] ) ) )

 

Month Measure = CALCULATE ( [Count Analysis Result], FILTER ( ALL(Calendar), Calendar[Month Number] = MAX( Calendar[Month Number] ) ), FILTER ( ALL(Calendar), Calendar[Year] = MAX( Calendar[Year] ) ) )

@mattbrice, thank you for the measures!

 

However, I forgot to say that I am working in DirectQuery mode. So, I receive the following error message after writing the "Week Measure".

 

Function 'FILTER' is not supported in this context in DirectQuery mode.

 

Any workaround for this?

I'm ok, I found the following thread that resolved my problem.

https://community.powerbi.com/t5/Desktop/Filter-is-not-working-in-Direct-query-mode/td-p/133492

 

@mattbrice, thanks again for the measures!

Hi @Jonathan_P,

 

Glad to hear you have resolved your problem. Please kindly mark the correspoind reply as an answer so that some other community members having similar concern can find the solution more easily. 

 

Thanks,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors