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
Goldfinch
New Member

DAX - calculate the total based on average country value and per year

Hi Guys,

 

For a project, I'm trying to show the total amount of sales. This total is dependent on the selected years (e.g. 2018 and 2019) and is always made for all countries in one box showing 1 total number. I've had some problems with getting the two criteria to work being (i) Year and (ii) Country code.

 

The amount need to be summed based on the years selected and all countries. Sometimes a country code will appear multiple times for 1 year because multiple entities are located in the same country but the sales amount is on country level so appears 3 times when you have for example 3 entities - see BE where you have 3x the country total sale amount.

 

I was tried making an average of the amounts based on country code and then using and SUMX and hasonevalue to get the total amount. But the hasonevalue only takes 1 criteria and does not take into account each year selected but delivers a total for all years - same problem if I reverse it.

 

Does anyone have any idea on how to tackle this?

 

Var_YearVar_Country codeSales amount
2018BE2.000
2018BE2.000
2018BE2.000
2019BE4.000
2019BE4.000
2019BE4.000
2018FR500
2019FR7.000
2018GB1.000
2019GB3.000

 

1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

[Total] =
    SUMX(
        DISTINCT( T ),
        T[Sales Amount]
    )

View solution in original post

1 REPLY 1
daXtreme
Solution Sage
Solution Sage

[Total] =
    SUMX(
        DISTINCT( T ),
        T[Sales Amount]
    )

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.

Top Solution Authors