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
CasperSV
Helper II
Helper II

Calculating nr of days and average nr of sales based on Calendar filter

Hi all,

 

I am trying to calculate the 'Number of days' and 'Average number of sales per month' based on the between dates slicer.

CasperSV_0-1642776091597.png

 

The number of days is not changing to the desired 306 days from march 2021 till december 2021.

CasperSV_1-1642776189120.png

Dag=Day, Kalender=Calendar 

 

The average is not working as well :'/, It should devide 13 with 10 months. But there were no sales in July, August and December, so the the dax devides the total sales with 7.

CasperSV_2-1642776431238.png

Maand=month

 

Do you guys have any idea how to fix this?

 

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@CasperSV change your measure to

 

Number of Days = COUNTROWS ( Kalendar )

 

and remove  .maand in your average measure.

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

v-yalanwu-msft
Community Support
Community Support

Hi, @CasperSV ;

Try it.

Average sales = DIVIDE([Number of Sales], COUNTROWS( SUMMARIZE('Kalendar',[Date].[Year],[Date].[Month])))

I tested it, and it should work. Looking forward to your reply

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @CasperSV ;

Try it.

Average sales = DIVIDE([Number of Sales], COUNTROWS( SUMMARIZE('Kalendar',[Date].[Year],[Date].[Month])))

I tested it, and it should work. Looking forward to your reply

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It worked! 

 

Thanks a lot guys.

CasperSV
Helper II
Helper II

Hi guys,

 

no one any idea how to fix the average number of sales per month?

When I remove .maand (.month), the average is 1:

CasperSV_0-1643015980688.png

 

When adding .maand (.month), the average is 2 (which is correct):

CasperSV_1-1643016070715.png

 

 

However, as soon as there are no sales in July and August, the average stays 2 but it should change to 1,2.

Hope you guys know the solution.

 

 

 

 

 

parry2k
Super User
Super User

@CasperSV change your measure to

 

Number of Days = COUNTROWS ( Kalendar )

 

and remove  .maand in your average measure.

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi Parry2k,

 

Thanks! The Number of days is now working 😊

 

However, removing .maand did not work :'/. 

CasperSV_0-1642785356251.png

 

It should be 1,083333 and dynamic based on the between calendar slicer.

Hi @CasperSV ,

When you are doing AVERAGEX, if your data is at the level of date, the AverageX is going to be done by number of days.

 

Instead you can try using DIVIDE function to get the sales by month. Something like the one below

Mymeasure = DIVIDE(SUM(table1[Sales]), DISTINCTCOUNT(table[Date].[Month]))

May be if you can share more info on how your data looks, ppl. in the community might be able to help you

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.