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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Wrong sub-total with IF function

Hi everybody,

 

i've a problem with a sub-total of a calculated matrix. I'm starting to say that my english is not so good, so please be patient.
I have a quantity, an average price and an import about the current year.

I want to convert only one category with azienda_id=84 (third row) from dollars to euros. The other two category are already in euros.

So i create a calculated metric, Imp CY: 

IF(MAX(VIEW_PBI_AVGI[AZIENDA_ID]) = "84", VALUE(VIEW_PBI_AVGI[Imp_Base CY] / 1.18), VALUE(VIEW_PBI_AVGI[Imp_Base CY]))

 

nikolas_fregni_0-1646155914503.png

How may you see, the sub-total is wronged and i don't understand the problem.

Each single row is correct, only the third row are correctly converted, while the first and second row are not converted.

The sub-total, in this case, is the sum of all rows, but each row is converted, not only the third!

 

Why? I really don't understand.

 

Thank you for the support.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please try the below.

If it does not work, please share your sample pbix file, and then I can try to look into it to come up with accurate solution.

 

New measure: =
SUMX (
VALUES ( tablename[Qty CY] ),
CALCULATE (
IF (
MAX ( VIEW_PBI_AVGI[AZIENDA_ID] ) = "84",
VALUE ( VIEW_PBI_AVGI[Imp_Base CY] / 1.18 ),
VALUE ( VIEW_PBI_AVGI[Imp_Base CY] )
)
)
)


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please try the below.

If it does not work, please share your sample pbix file, and then I can try to look into it to come up with accurate solution.

 

New measure: =
SUMX (
VALUES ( tablename[Qty CY] ),
CALCULATE (
IF (
MAX ( VIEW_PBI_AVGI[AZIENDA_ID] ) = "84",
VALUE ( VIEW_PBI_AVGI[Imp_Base CY] / 1.18 ),
VALUE ( VIEW_PBI_AVGI[Imp_Base CY] )
)
)
)


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thank you so much, SUMX function save me!

VijayP
Super User
Super User

@Anonymous 

Change "84" to just 84 since it is a number data type . You will get your result ! Share your Kudos!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


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.