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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Fistachpl
Helper II
Helper II

Calculating the average factor for months with data

Hello,

I have a visual a table with:
Month - name of the month
Avg Sale Per Year - average sale in Januaries, Februaries etc. from selected timeframe
Sold CY - sold in current year in each month
AvgWsp - factor comparing the amount of Sold in Current year divided by Average Sale per Year

Fistachpl_0-1717947983919.png


Now I need to calculate the average factor this means:

VAR _sumOfFactors =
    CALCULATE(
        SUMX(ALLNOBLANKROW('TMiesiące'[Nr miesiąca]);[AvgWsp]);
        REMOVEFILTERS('TMiesiące'[Month])
    )
Which is correctly calculated.

How can I calculate the amount of calculated factors - in this case the answer is 5.
1 ACCEPTED SOLUTION

Hi @Fistachpl 

 

Did you apply sort by column to the Month field? If so, please add the sort reference field to the ALL function as well, you can try below measure.

 

AvgWsp over the year = COUNTX(ALL('TMiesiące'[Month],'TMiesiące'[Month Number]),[AvgWsp])

// Change the 'TMiesiące'[Month Number] to your acthal name, which should be use to sort by column setting.

 

For the rationale for doing this, pls see my answer in another thread.

 

https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-function-on-a-specific-column-no...

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

View solution in original post

4 REPLIES 4
Fistachpl
Helper II
Helper II

Tomorrow I will read about this sorting but I did not have top change the sorting in any way. It worked perfectly. 

Thank You!

 

xifeng_L
Super User
Super User

Hi @Fistachpl 

 

I'm not sure if I understood your question correctly, you can try this measure.

 

 

Amount of factors = SUMX(ALL('TMiesiące'[Month]),[AvgWsp over the year])

 

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

This calculates the sum of those but to get average factor I need to calculate the sum (which I already have) and divide it by the number of factors to get the average factor.

 

I tried to calculate by:

VAR _amountOfFactors =
    CALCULATE(
        COUNTX(ALL('TMiesiące'[Month]);[AvgWsp]);
        FILTER(ALL('TMiesiące'[Month]);[AvgWsp]>0)
    )


and got: 

Fistachpl_0-1717954557459.png

But in the table I want to have 5. 
I know I can just use:

VAR _amountOfFactors = MONTH(now())-1 (with safety for January so I do not get 0) but I want to learn 🙂
 

Fistachpl_0-1717956063071.png

 




Hi @Fistachpl 

 

Did you apply sort by column to the Month field? If so, please add the sort reference field to the ALL function as well, you can try below measure.

 

AvgWsp over the year = COUNTX(ALL('TMiesiące'[Month],'TMiesiące'[Month Number]),[AvgWsp])

// Change the 'TMiesiące'[Month Number] to your acthal name, which should be use to sort by column setting.

 

For the rationale for doing this, pls see my answer in another thread.

 

https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-function-on-a-specific-column-no...

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.