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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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
v-shex-msft
Community Support
Community Support

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

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

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.