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

Measure with top 3

Hi all. I have a few tables with data and I'm sharing some examples of what they contains.

 

This table contains general ledger transactions.

tnaess_4-1709555481123.png

 

This table contains the main accounts with its transaction type. Here the accouning year is added since the transaction type on an account can change from year to year.

tnaess_3-1709555452795.png

 

This table contains financial dimension values for the dimension 'Motpart'

tnaess_0-1709557242344.png

 

The model view is like this:

 

tnaess_7-1709555926651.png

 

Please note that the data above are only example data which doesn't add up in total.
 

I've created a simple report with table layout where I show the following columns:

- Name --> This is the legal entity name

- Controlled transactions --> This is the "Controlled transactions" from the MainAccountMapping table

- SUM --> This is a measure, showing the formula below

 
CONTROLLED TRANSACTIONS TOTAL =
CALCULATE(
    SUM('GJAE Trans'[REPORTINGCURRENCYAMOUNT]) * -1,
    FILTER(
        ALLSELECTED('MainAccountMapping'[Controlled transactions]),
        ISONORAFTER('MainAccountMapping'[Controlled transactions], MAX('MainAccountMapping'[Controlled transactions]), DESC)
    )
)

 

All this is obviously quite simple and is working as expected. What I want is a new column that is showing the country code from the table "MotpartSettings" for the top 3 motpart for the calculated sum on the report. Something like this:

 

tnaess_8-1709556037188.png

Any ideas on how to solve this?

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @tnaess ,

Please try this measure:

Country Code = CONCATENATEX(TOPN(3,CALCULATETABLE(VALUES('MotpartSettings'[COUNTRYCODE])),[CONTROLLED TRANSACTIONS TOTAL],DESC),'MotpartSettings'[COUNTRYCODE],"|")

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Hi @v-cgao-msft ,

 

thanks a lot. Just one additional question, how do I adjust the number of contry codes to be the same as the top3? At the moment it lists more than three values.

 

tnaess_0-1709637976826.png

 

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.