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
Anonymous
Not applicable

Create a measure that calculates sum of distinct values over multiple columns in a table

My table has following structure:

Knipsel.PNG

 

In this table, if a combination of country and case have multiple weapons involved, the value shall be contained in those multiple rows(for example the 200 in row 2 and 3 here). However, I want to be able to create a table visual that gives the sum of the value per country, taking into account that only the distinct values per country and case should be summed up.

Table should look like this:

Germany 300

Belgium 200

Netherlands 100.

I'd like to use a calculated measure for this, but not sure how to code it. Can someone help me?
Regards,
Sander

1 ACCEPTED SOLUTION
CheenuSing
Community Champion
Community Champion

Hi @Anonymous 

 

Try this

 

Totals =
SUMX (
    SUMMARIZE (
        Country,
        Country[Country],
        Country[Case],
        "Value", DISTINCT ( Country[Value] )
    ),
    [Value]
)

Replace Country by your tablename.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
CheenuSing
Community Champion
Community Champion

Hi @Anonymous 

 

Try this

 

Totals =
SUMX (
    SUMMARIZE (
        Country,
        Country[Country],
        Country[Case],
        "Value", DISTINCT ( Country[Value] )
    ),
    [Value]
)

Replace Country by your tablename.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Hi @Anonymous ,

 

I forgot to add the following lines.

 

Now create a table visual with Country and Totals

 

You will get your desired result.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
vanessafvg
Super User
Super User

@Anonymous  hi can you explain the rule a bit better, why for germany is it only 300 and not 400?  there doesnt seem to be a clear rule for which row you want if there is more than one.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

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.