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
deepguptaac
Frequent Visitor

Average Daily sales problem

Hi, 

 

I am currently facing a peculiar problem related to average daily sales calculation.  My data set looks like this.

 

deepguptaac_0-1663049959159.png

 

I am calculating average daily sales by dividing total sales by the distinct number of stores opened. This gives me an accurate result for a day. 

However, for a week or month, the values come out to be inaccurate. Since in a month or week, some stores might be open for a particular day only and are counted by DISTINCTCOUNT DAX. So, now the total sales value for that period is being divided by a higher number of stores than the actual number of stores. This results in lower than actual average daily sales value.

Example of a result is as follows :

deepguptaac_1-1663050911494.png

Kindly help. 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @deepguptaac ,

 

Please try:

Measure =
VAR _a =
    SUMMARIZE ( 'Sales', [Date] )
VAR _b =
    ADDCOLUMNS (
        _a,
        "NumberOfStore",
            CALCULATE (
                DISTINCTCOUNT ( Sales[Store No_] ),
                FILTER ( _a, [Date] = EARLIER ( Sales[Date] ) )
            ),
        "Sales",
            - CALCULATE (
                SUM ( Sales[Net Amount] ),
                FILTER ( _a, [Date] = EARLIER ( Sales[Date] ) )
            )
    )
RETURN
    AVERAGEX ( _b, [Sales] / [NumberOfStore] )

Output:

vjianbolimsft_0-1663144712369.png

Best Regards,

Jianbo Li

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

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @deepguptaac ,

 

Please try:

Measure =
VAR _a =
    SUMMARIZE ( 'Sales', [Date] )
VAR _b =
    ADDCOLUMNS (
        _a,
        "NumberOfStore",
            CALCULATE (
                DISTINCTCOUNT ( Sales[Store No_] ),
                FILTER ( _a, [Date] = EARLIER ( Sales[Date] ) )
            ),
        "Sales",
            - CALCULATE (
                SUM ( Sales[Net Amount] ),
                FILTER ( _a, [Date] = EARLIER ( Sales[Date] ) )
            )
    )
RETURN
    AVERAGEX ( _b, [Sales] / [NumberOfStore] )

Output:

vjianbolimsft_0-1663144712369.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@deepguptaac , Can share the current measure.

 

Assume you want Avg of sum above day level

 

Averagex(Values(Date[Date]), calculate(Sum(Sales[Value])) )

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

@amitchandak  Please find the link for sample data for your better understanding.

 

https://drive.google.com/file/d/1O-SLkkMSFLvmItREYRqGIBL_zu3BMMEN/view?usp=sharing 

 

Here in the result in the total value for the selected period Average daily sales (ADS) should be 6716. However as total distinct store for that periods are 88 which is resulting in incorrect ADS. Store count should be average value for that period.

 

Thank 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.