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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jobf
Helper I
Helper I

LOOKUPVALUE of the factor with the highest value

Hello. I needed to create a measure to serve as a tooltip for a chart that showed the best-selling factor in that period. For example:

PeriodFactorSales
PE1P1120
PE1PM2139
PE2P2134
PE2PM1145
PE3P398
PE3PM3123


I had created a measure with the following code:

measure = LOOKUPVALUE('table'[Variety],'table'[Sales],max('table'[Sales]))

It worked well overall on the chart. But for some reason, when I filtered a specific factor, the chart would give an error, maybe because some factors did not have sales in all periods.
Anyway, I would appreciate if you could give me some ideas for new measures. A measure that shows which factor made more sales.
1 ACCEPTED SOLUTION
Irwan
Memorable Member
Memorable Member

hello @jobf 

 

i see, so it show factor instead of sales.

then you can change the expression MAXX from Sales into Factor.

More Sales = 
var _Period = SELECTEDVALUE('Table'[Period])
Return
MAXX(
    FILTER(
        ALL('Table'),
        'Table'[Period]=_Period
    ),
    'Table'[Factor]
)
Irwan_0-1725498038137.png
Irwan_1-1725498088606.png
Irwan_2-1725498107027.png

 

Hope this will help.

Thank you.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

This measure works

Tooltip = CONCATENATEX(TOPN(1,VALUES(Data[Factor]),[S]),Data[Factor]&" – "&FORMAT([s],"0")," | ",[s], DESC)

Hope this helps.

Ashish_Mathur_0-1725505273118.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Irwan
Memorable Member
Memorable Member

hello @jobf 

 

is this what you are looking for?

the value is still showing the highest value of selected Period.

the cursor is hovering at 120 in PE1 but the highest is 139 for PE1 so it shows 139.

Irwan_0-1725411927107.png

if yes, then please check this measure DAX.

More Sales = 
var _Period = SELECTEDVALUE('Table'[Period])
Return
MAXX(
    FILTER(
        ALL('Table'),
        'Table'[Period]=_Period
    ),
    'Table'[Sales]
)
 
Hope this will help.
Thank you.

No. The measure would be to show which factor made the largest number of sales in the period. For example, in period PE1, the factor that made the largest number of sales was PM2. In period PE2, the factor that made the largest number of sales was PM1. The measure is to show which factor made the largest number of sales.

Irwan
Memorable Member
Memorable Member

hello @jobf 

 

i see, so it show factor instead of sales.

then you can change the expression MAXX from Sales into Factor.

More Sales = 
var _Period = SELECTEDVALUE('Table'[Period])
Return
MAXX(
    FILTER(
        ALL('Table'),
        'Table'[Period]=_Period
    ),
    'Table'[Factor]
)
Irwan_0-1725498038137.png
Irwan_1-1725498088606.png
Irwan_2-1725498107027.png

 

Hope this will help.

Thank you.

Okay, now it's showing the factor, but there's a problem. The real table has several columns with numbers. I think the code is showing the factor whose value in all columns is the highest. Is there a way to specify in the code that it should show which factor had the highest sale value

Irwan
Memorable Member
Memorable Member

Hello @jobf 

 

Yes, it will calculate factor which has the highest value within same period since the applied filter only for period.

You can add them as filter. But please remember to add them as variable so it can get calculated.

 

Something like below

More Sales = 

var _Period = SELECTEDVALUE('Table'[Period])

var _1stFilter = SELECTEDVALUE('Table'[Filter1])

Return

MAXX(

    FILTER(

        ALL('Table'),

        'Table'[Period]=_Period&&Filter1&&(and so on..)

    ),

    'Table'[Factor]

)

 

Hope this will help.

Thank you.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.