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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
binayjethwa
Helper IV
Helper IV

Display Column name of Max value from list of columns

Hi , I have the following scenario , where 

 

I have Sales1, Sales 2,Sales 3, Sales 4, Sales 5 Columns in my table , now i have another column sales % which will give my % sales , so if Sales % is between 1 and 50 percent , i should check for all the columns from sales 1 to sales 5 and return column name which has maximum value . Check below table for reference. 

 

I am looking to create  result column , for example for Emp Binay sales % is 5% so i will have to check all columns from sales 1 to sales 5 and return the column name for which it has higher values , in this case its sales 3 since it has 19 

similary for Binay 3 , max value from columns sales 1 to 5 in that row is 33 , so the result will be sales 5.

 

Note:  This is a sample table , i have other columns also in my table. But i am specifically looking to build Result column.

 

Please help with this scenario.

 

EMP nameEmp NoSales 1Sales 2Sales 3Sales 4Sales 5Sales % Result
Binay12230019005%Sales 3
Binay1122403319007%Sales 2
Binay212251122191049%Sales 2
Binay31226231903311%Sales 5
Binay41227011944022%

Sales 4

 

Thanks,

Binay

1 ACCEPTED SOLUTION

[sales%] this measure?
try this

 

Max Columnname_Measure=

VAR t1 = sum ('Table'[Sales 1])
VAR t2 = sum ('Table'[Sales 2])
VAR t3 = sum ('Table'[Sales 3])
VAR t4 = sum ('Table'[Sales 4])
VAR t5 = sum ('Table'[Sales 5])
VAR _maxDate =MAXX({[t1],[t2],[t3],[t4],[t5]},[Value])
RETURN
IF(
[sales%] >=0.01&& [sales%] <=0.05,
SWITCH(_maxDate,
t1,"Sales 1",
t2,"Sales 2",
t3,"Sales 3",
t4,"Sales 4",
t5,"Sales 5"
))

 

View solution in original post

7 REPLIES 7
binayjethwa
Helper IV
Helper IV

Hi @Ahmedx , 

 

 I have used the above as a measure and i see below table , i am pulling all my sales values to tables and it gives me sum of sales 1 , sum of sales 2 etc and i am not doing dont summarize here , and now i have other column sales % for which if it is between 1% to 50 % then the  measure condition should apply. But i did the same and i am seeing below values .

I have created the measure as below. 

 

Max Columnname_Measure=

VAR t1 = sum ('Table'[Sales 1])
VAR t2 = sum ('Table'[Sales 2])
VAR t3 = sum ('Table'[Sales 3])
VAR t4 = sum ('Table'[Sales 4])
VAR t5 = sum ('Table'[Sales 5])
VAR _maxDate =MAXX({[t1],[t2],[t3],[t4],[t5]},[Value])
RETURN
IF(sales%)>=0.01 && sales% <=0.05,
SWITCH(_maxDate,
t1,"Sales 1",
t2,"Sales 2",
t3,"Sales 3",
t4,"Sales 4",
t5,"Sales 5"
),blank())

 

 

Here the highlighted values with % between 1 and 50% although the values are there i am seeing blank. 

binayjethwa_1-1692272927894.png

 

 

1. If all values are blank i am seeing the 

binayjethwa_0-1692272496775.png

 

[sales%] this measure?
try this

 

Max Columnname_Measure=

VAR t1 = sum ('Table'[Sales 1])
VAR t2 = sum ('Table'[Sales 2])
VAR t3 = sum ('Table'[Sales 3])
VAR t4 = sum ('Table'[Sales 4])
VAR t5 = sum ('Table'[Sales 5])
VAR _maxDate =MAXX({[t1],[t2],[t3],[t4],[t5]},[Value])
RETURN
IF(
[sales%] >=0.01&& [sales%] <=0.05,
SWITCH(_maxDate,
t1,"Sales 1",
t2,"Sales 2",
t3,"Sales 3",
t4,"Sales 4",
t5,"Sales 5"
))

 

Ahmedx
Super User
Super User

Is this what you are looking for?

Column = 
 VAR _EMP = [EMP name]
VAR _tbl = FILTER(ALL('Table'),'Table'[EMP name]=_EMP)
VAR t1 = MAXX(_tbl,[Sales 1])
VAR t2 = MAXX(_tbl,[Sales 2])
VAR t3 = MAXX(_tbl,[Sales 3])
VAR t4 = MAXX(_tbl,[Sales 4])
VAR t5 = MAXX(_tbl,[Sales 5])
VAR _maxDate = MAXX({t1,t2,t3,t4,t5},[Value])
RETURN 
SWITCH(_maxDate,
        t1,"Sales 1",
        t2,"Sales 2",
        t3,"Sales 3",
        t4,"Sales 4",
        t5,"Sales 5"
)

Screenshot_1.png

binayjethwa
Helper IV
Helper IV

Hi @Ahmedx , I have tried the dax shared but since the data is summarized in the table i am seeing many rows for single employee. Because one person can have multiple rows in table. And my sales is Sum(sales) which i aggregated in table visual. currently i see result as many rows in my data .  But it should be ony one row.

 

Thanks,

Binay

 

well, you need to aggregate them in a matrix and write such a measure

t1 = sum ('Table'[Sales 1])
t2 = sum ('Table'[Sales 2])
t3 = sum ('Table'[Sales 3])
t4 = sum ('Table'[Sales 4])
t5 = sum ('Table'[Sales 5])
--------------------------
Measure = 
VAR _maxDate =MAXX({[t1],[t2],[t3],[t4],[t5]},[Value])
RETURN
SWITCH(_maxDate,
        t1,"Sales 1",
        t2,"Sales 2",
        t3,"Sales 3",
        t4,"Sales 4",
        t5,"Sales 5"
)

 could you share your pbix-file? Or create an example file which reproduces your issue?

Ahmedx
Super User
Super User

or

 

Column = 
VAR t1 = [Sales 1]
VAR t2 = [Sales 2]
VAR t3 = [Sales 3]
VAR t4 = [Sales 4]
VAR t5 = [Sales 5]
VAR _maxDate =MAXX({t1,t2,t3,t4,t5},[Value])
RETURN
SWITCH(_maxDate,
        t1,"Sales 1",
        t2,"Sales 2",
        t3,"Sales 3",
        t4,"Sales 4",
        t5,"Sales 5"
)

 

Screenshot_4.png

Ahmedx
Super User
Super User

pls try this

Column = 
VAR t1 = CALCULATE(MAX('Table'[Sales 1]))
VAR t2 = CALCULATE(MAX('Table'[Sales 2]))
VAR t3 = CALCULATE(MAX('Table'[Sales 3]))
VAR t4 = CALCULATE(MAX('Table'[Sales 4]))
VAR t5 = CALCULATE(MAX('Table'[Sales 5]))
VAR _maxDate =MAXX({t1,t2,t3,t4,t5},[Value])
RETURN
SWITCH(_maxDate,
        t1,"Sales 1",
        t2,"Sales 2",
        t3,"Sales 3",
        t4,"Sales 4",
        t5,"Sales 5"
)

Screenshot_3.png

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors