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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Yuiitsu
Helper V
Helper V

Average based on the number of months that have revenue

Hi All

 

I need help on this result that I wish to get

Example: 

I want to get the average revenue of customer X based on the last 6 months. (Or any amount of months I choose in the slicer)

So in the slicer I choose the last 6 months (May till Oct) , however customer X does not have revenue every month.

Based on the screenshot below, X only have revenue on June and July. So I need the formula to work this way:

362,640 / 2 = 181,320

Yuiitsu_0-1700635196589.png

 

Similarly if i choose another customer Y now that only have sales for 4 months.

The formuala should be:

680,254 / 4 = 170,064

Yuiitsu_1-1700635367897.png

Tried using the average function but the result is not accurate.

Yuiitsu_2-1700635466799.png

Yuiitsu_4-1700635493617.png

 

Any idea how to write this DAX?

(I tried to 1st create a measure to count month if revenue is not blank but i think it is not working. The result is always the number of month i choose in the slicer and not how many months have revenue)

MonthCount = 
    CALCULATE(
        DISTINCTCOUNT('Date'[Month Name]),
            NOT(
                ISBLANK('Master Sales'[Revenue]
                
            )
        ))

 

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

Hi @Yuiitsu ,

I noticed in the posted image that [Revenue] is not aggregated, at this point it passes a screener up filter to [Average of Revenue ], please try changing [Revenue] to [Sum of Revenue], at this point [Average] should work.

vcgaomsft_1-1700791022936.png
Please check the pbix file.

vcgaomsft_0-1700790988848.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @Yuiitsu ,

I noticed in the posted image that [Revenue] is not aggregated, at this point it passes a screener up filter to [Average of Revenue ], please try changing [Revenue] to [Sum of Revenue], at this point [Average] should work.

vcgaomsft_1-1700791022936.png
Please check the pbix file.

vcgaomsft_0-1700790988848.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors