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

Ignore blanks in Grand Total calculation

Hello,

I am trying to divide the cost of injectables by pigs produced by group to get to an injectable cost per pig produced.  Some groups will not have injectables as it is N/A to them; thus, it is blank in the data.  All groups will have pigs produced.  I've been able to accurately calculate the cost per pig produced, but the grand total is not calculating properly.  How should I update my formula below so it ignores the groups that do not have injectable amounts (i.e. blanks)?  I believe the total in the example below should be $0.1356 not $0.0505.  Note, the formula below was written with the intention that the result is only shown at the "Yr-Wk-Site" level as well as the Total level.  Thank you.

 

Inject / pig =
IF (
(
ISFILTERED ( MetaFarms_FinishGroups[Yr-Wk-Site] )
&& NOT ( ISFILTERED ( MetaFarms_FinishGroups[Producer] ) )
),
DIVIDE (
AVERAGEX ( 'Nursery Drug Costs', 'Nursery Drug Costs'[Injectables Cost] ),
CALCULATE ( SUM ( MetaFarms_FinishGroups[PigsProduced] ) ),
BLANK ()
)
)
Snapshot.JPG
Thanks,
 
2 REPLIES 2
gckcmc
Resolver I
Resolver I

try:

 

Result =
AVERAGEX ( FILTER ( Table, Table[Value] <> BLANK () ), Table[Value] )
Inject / pig =
IF (
(
ISFILTERED ( MetaFarms_FinishGroups[Yr-Wk-Site] )
&& NOT ( ISFILTERED ( MetaFarms_FinishGroups[Producer] ) )
),
DIVIDE (
AVERAGEX ( 'Nursery Drug Costs', 'Nursery Drug Costs'[Injectables Cost] <> BLANK() ),
CALCULATE ( SUM ( MetaFarms_FinishGroups[PigsProduced] ) ),
BLANK ()
)
)

 

trk26
Frequent Visitor

Thank you for the suggestion.  After I tried your suggestion, I received the following calculation error message, " The function AVERAGEX cannot work with values of type Boolean."

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.