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
SelflearningBi
Helper III
Helper III

How to fix display TOTAL in x-axis question

Please help out how to fix these dax functions. I would like to display Total of average (price1 vs price 2) by brand level in the last column.  Somehow if any brands price 1 or price 2 is empty, the graphic automality displays total avergae for that brand.  I just want to display nothing insteand of total average 10.8 as I highlighted in circle. 

SelflearningBi_1-1652325379024.png

1 =
var amount = average('Quotation Dynamic_Page'[FOB_Price])
return if(ISBLANK(amount), CALCULATE(AVERAGE('Quotation Dynamic_Page'[FOB_Price]), ALLEXCEPT('Quotation',Quotation[Brand] )),amount)
 
 
2 =
var amount = average(Quotation[Target_Price_From])
return if(ISBLANK(amount),CALCULATE(AVERAGE(Quotation[Target_Price_From]), ALLEXCEPT('quotation',Quotation[Brand] )),amount)
 
 
 
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @SelflearningBi ,

 

Is your Total column a new column? Below is my solution.

1.Create a new calculated table to use your brand column and add a total value.

ChartAxis = UNION ( VALUES ('Table'[Brand] ), ROW ( "Brand", "Total" ) )

vstephenmsft_1-1652862159512.png

 

2.Create two measures.

Measure1 =
IF (
    MAX ( 'ChartAxis'[Brand] ) = "Total",
    CALCULATE ( AVERAGE ( 'Table'[Price1] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) ),
    CALCULATE (
        SUM ( 'Table'[Price1] ),
        FILTER ( 'Table', [Brand] = MAX ( 'ChartAxis'[Brand] ) )
    )
)
Measure2 =
IF (
    MAX ( 'ChartAxis'[Brand] ) = "Total",
    CALCULATE ( AVERAGE ( 'Table'[Price2] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) ),
    CALCULATE (
        SUM ( 'Table'[Price2] ),
        FILTER ( 'Table', [Brand] = MAX ( 'ChartAxis'[Brand] ) )
    )
)

vstephenmsft_2-1652862219816.png

 

Best Regards,

Stephen Tao

 

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

5 REPLIES 5
v-stephen-msft
Community Support
Community Support

Hi @SelflearningBi ,

 

Is your Total column a new column? Below is my solution.

1.Create a new calculated table to use your brand column and add a total value.

ChartAxis = UNION ( VALUES ('Table'[Brand] ), ROW ( "Brand", "Total" ) )

vstephenmsft_1-1652862159512.png

 

2.Create two measures.

Measure1 =
IF (
    MAX ( 'ChartAxis'[Brand] ) = "Total",
    CALCULATE ( AVERAGE ( 'Table'[Price1] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) ),
    CALCULATE (
        SUM ( 'Table'[Price1] ),
        FILTER ( 'Table', [Brand] = MAX ( 'ChartAxis'[Brand] ) )
    )
)
Measure2 =
IF (
    MAX ( 'ChartAxis'[Brand] ) = "Total",
    CALCULATE ( AVERAGE ( 'Table'[Price2] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) ),
    CALCULATE (
        SUM ( 'Table'[Price2] ),
        FILTER ( 'Table', [Brand] = MAX ( 'ChartAxis'[Brand] ) )
    )
)

vstephenmsft_2-1652862219816.png

 

Best Regards,

Stephen Tao

 

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

 

@v-stephen-msft Hi thank you for helping, i was wondeing what if my price1 and price 2 is a measure.  for example price 1 is percentage of On Time Shipped Quantity and Price 2 is percentage of ON TIME shipped Value.  In your formula Calculate (Average( ) ),,, only avaiable for column. is it possible also work for Measure? 

FarhanAhmed
Community Champion
Community Champion

your DAX statement is saying itself "If it is your average of single brand is BLANK then it is calculating average of all the brands"

I think you are trying to calculate average for totals and you need to put statement like this

 

Old: if(ISBLANK(amount), CALCULATE(AVERAGE('Quotation Dynamic_Page'[FOB_Price]), ALLEXCEPT('Quotation',Quotation[Brand] )),amount)

 

New One:

if(ISBLANK(amount) && NOT (HASONEVALUE(Quotation[Brand]), CALCULATE(AVERAGE('Quotation Dynamic_Page'[FOB_Price]), ALLEXCEPT('Quotation',Quotation[Brand] )),amount)

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




@FarhanAhmed Hi thank you for helping. I try your formula but still doesnt work. It still shows the average of totals for those blank brand. 

2 =
var amount = average(Quotation[Target_Price_From])
RETURN if(ISBLANK(amount)&& NOT(HASONEVALUE(Quotation[Brand])),CALCULATE(AVERAGE(Quotation[Target_Price_From]), ALLEXCEPT('Quotation',Quotation[Brand] )),amount)
SelflearningBi_0-1652340191657.png

 

Can you please share the sample data of your problem. Try this too

 

if(ISBLANK(amount), BLANK(),if(ISBLANK(amount) && NOT (HASONEVALUE(Quotation[Brand]), CALCULATE(AVERAGE('Quotation Dynamic_Page'[FOB_Price]), ALLEXCEPT('Quotation',Quotation[Brand] )),amount))







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




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.