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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Count of Orders Expected in a Month

Hello everyone,

my issue is that I have this measure:

 

 

Test Conteggio = 
IF(
CALCULATE(
DISTINCTCOUNT(Calendario[Settimana]),DATESBETWEEN(Calendario[Date],STARTOFMONTH(Calendario[Date]),ENDOFMONTH(Calendario[Date])
)
) > = 6, 8, 6)

 

that returns a numerical value to changes in the number of weeks within a month.

 

So, when I filter for a single month, the measure returns the expected result.
Ex:

Immagine 2021-04-29 102714.png

 

But, when I try to remove the filter "Anno, Mese", the measure doesn't work correctly and doesn't return the expected result. 

 

Immagine 2021-04-29 103054.png 

 

I would like to have the overall sum of the measure for all the months.

 

Immagine 2021-04-29 103338.png

 

According to the expected result, I should have 24 and not 8.

 

Thanks,

Domenico.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Anonymous,

According to your description, it seems like measure total level calculation issues when you try to apply multiple aggregates.
For this scenario, I'd like to suggest you take a look at the following blog and it told about how to resolve this issue:

Measure Totals, The Final Word 

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @Anonymous,

According to your description, it seems like measure total level calculation issues when you try to apply multiple aggregates.
For this scenario, I'd like to suggest you take a look at the following blog and it told about how to resolve this issue:

Measure Totals, The Final Word 

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , Try like

 

Test Conteggio =
var _max = eomonth(maxx(allselected('Calendario'), 'Date'[Date]),0)
var _min= eomonth(minx(allselected('Calendario'), 'Date'[Date]),-1)+0
IF(
CALCULATE(
DISTINCTCOUNT(Calendario[Settimana]),DATESBETWEEN(Calendario[Date],_min,_max
)
) > = 6, 8, 6)

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi, thank you for your reply. 

I've just tried to use the measure you suggested me but the formula doesn't work correctly.

I try to better explain the data and the sample.
There is a table that contains sales orders. I want to count the number of distinct orders in the table (I do this by checking count (distinct) from the "values" field) and compare it to a hypothetical number of orders that depends on the number of weeks in a month. I used the "Test Conteggio" measure mentioned before to calculate the hypothetical number of orders, but when filtering the table for a given set of months, the measure doesn't consider the sum of the hypothetical orders in filtered periods.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.