Forum Discussion
Exclude Blank Measure Values From Average Calculation
Hello, I am looking for some direction on excluding blank measure values from my average cost per square foot calculation. I am not using AVERAGE, because I have to do the cost per sqft calculation first. See example below. The desired result would be for the total average to be 10.00, but the Division 1/Product A Janurary thru June months w/no data, is causing the total average to be 7.50 instead. This is all driven by the date slicer. If the slicer is changed to 7/1/2020 thru 12/31/2020, then it works as ecpected with a total average of 10.00. The below is a simplified version of my actual data and I have the pbix for the example below, I'm just not sure how to upload or link it. I provided the simple table of data, along with my calculated columns and measures.
Any help would be greatly appreciated,
| Division | Product | SQFT | YearMonth | Cost |
| Division 1 | ProductA | 10 | 2020 Jul | 100 |
| Division 1 | ProductA | 10 | 2020 Aug | 100 |
| Division 1 | ProductA | 10 | 2020 Sep | 100 |
| Division 1 | ProductA | 10 | 2020 Oct | 100 |
| Division 1 | ProductA | 10 | 2020 Nov | 100 |
| Division 1 | ProductA | 10 | 2020 Dec | 100 |
| Division 2 | ProductB | 10 | 2020 Jan | 100 |
| Division 2 | ProductB | 10 | 2020 Feb | 100 |
| Division 2 | ProductB | 10 | 2020 Mar | 100 |
| Division 2 | ProductB | 10 | 2020 Apr | 100 |
| Division 2 | ProductB | 10 | 2020 May | 100 |
| Division 2 | ProductB | 10 | 2020 Jun | 100 |
| Division 2 | ProductB | 10 | 2020 Jul | 100 |
| Division 2 | ProductB | 10 | 2020 Aug | 100 |
| Division 2 | ProductB | 10 | 2020 Sep | 100 |
| Division 2 | ProductB | 10 | 2020 Oct | 100 |
| Division 2 | ProductB | 10 | 2020 Nov | 100 |
| Division 2 | ProductB | 10 | 2020 Dec | 100 |
Calulated columns and measures:
18 Replies
- amitchandakSuper User
curtismob , This formula seems fine, remove 0 from first divide and check
CALCULATE(DIVIDE(DIVIDE([_mCost Per SQFT],[_mDistinctCount YYYMM]), DISTINCTCOUNT('CostPerSqft'[Product]), 0))
- curtismobHelper IV
amitchandak, thank you for the response. Unforrtunately, that did not resolve my issue.
- AnonymousNot applicable
Hi curtismob,
I think this may be related to your measure formula who setting the 0 in divide functions. You can add an if statement to check the current row count to confirm they not blank.
Regards,
Xiaoxin Sheng
- curtismobHelper IV
Anonymous,
Thank you for the response. Can you provide an "if" statement example using the measures I provide initially? Everything I have tried doesn't appear to work.
Thank you,
Curtis
- AnonymousNot applicable
HI curtismob,
You can try to use the following measure formula, I added the if statement to check hierarchy level and write a formula for the calculation on measure total level:
_mAvg Cost Per SQFT per Product = VAR detailLevel = CALCULATE ( DIVIDE ( DIVIDE ( [_mCost Per SQFT], [_mDistinctCount YYYMM], 0 ), DISTINCTCOUNT ( [Product] ), 0 ) ) VAR totalLevel = DIVIDE ( CALCULATE ( SUM ( 'CostPerSqft'[_cCost Per SQFT] ), ALLSELECTED ( 'CostPerSqft' ) ), SUMX ( SUMMARIZE ( CostPerSqft, [Area], [Division], [Product], "DC", DISTINCTCOUNT ( CostPerSqft[_cYYYY Mon] ) ), [DC] ), 0 ) RETURN IF ( ISINSCOPE ( CostPerSqft[_cYYYY Mon] ), detailLevel, IF ( ISINSCOPE ( CostPerSqft[Division] ), detailLevel, totalLevel ) )Regards,
Xiaoxin Sheng
- Ashish_MathurSuper User
Hi,
Upload your PBI file to Google Drive and share the download link here.
- curtismobHelper IV
Ashish,
Thank you for responding, please see link below.
https://drive.google.com/file/d/1v01ZpHo2XRy3LJSODzDEsOfXlF2iYsZp/view?usp=sharing
- Ashish_MathurSuper User
- AnonymousNot applicable
HI curtismob,
Did Ashish_Mathur's formula help for your scenario? If this is a case, you can consider accepting his suggestion to help others who faced a similar requirement to find it more quickly.
If not, you can feel free to post here with detailed descriptions to help us clarify your scenario.
Regards,
Xiaoxin Sheng