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
ganchevd
Helper I
Helper I

Calculate the difference from the MAX value in a column

Hi,

 

I have an issue with the MAX value formulas in Power BI. I use it quite simple in Excel but it is different in Power BI. So the Excel formula I use looks like: =C2/MAX($C$2:$C$27). which I use to measure all the customers to the one with highes revenue for me. Here is the sample table:

CustomerRevAnnualRanking
A249 5550.17
B438 2880.29
C1 495 9951.00
D196 1240.13
E149 7050.10
F151 1670.10
H107 8100.07
I174 6980.12
J123 4900.08
K154 0950.10
L135 0930.09
M118 2230.08
N168 2220.11
O201 8190.13
P177 1260.12
Q695 8920.47
R145 8660.10
S283 4750.19
T158 2900.11
U307 1960.21
V114 6650.08
W218 9400.15
X134 4890.09
Y227 2150.15
Z117 0360.08
AA210 7600.14

 

In the attached table the RevAnnual is a Measure column in my report. Can someone help me figure out how to do this? Thank you in advance

2 ACCEPTED SOLUTIONS
PattemManohar
Community Champion
Community Champion

@ganchevd Here it is..

 

Ranking = TestMax[RevAnnual]/MAX(TestMax[RevAnnual])

 image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

19 REPLIES 19
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @ganchevd,

 

Have you solved your problem?

 

If you have solved, please accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

 

If you still need help, please share your desired output so that we could help further on it.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Well the desired output is what @PattemManohar showed and @Fcoatis in his fist proposal of a solution. Still it is far more complicated since I use direct link to the SQL database of MS DynamicsNAV and I have the information from three tables which i use to obtain the sample above. This was misleading to everyone who tried to help.

 

So. I have a table of Sales. There I have approximately 1m postings. I have a table Customer, which is linked to the Sales table by the uniqe CustomerNo. I have a third table which is the Differed Rev. And I made a measure to subtract from the differed rev from the sales, so that I'd be able to have a clear view over the revenue. In the visual table I'd shared I used as follows: Customer Name column from table customers and the RevAnnual measure. I am still not able to calculate the deviation of each customer revenue compared to the customer with the MAX revenue. It is easy in Excel but I'd like to be able to abandone these exports and justification of the data from NAv to Excel and make it life.

PattemManohar
Community Champion
Community Champion

@ganchevd Here it is..

 

Ranking = TestMax[RevAnnual]/MAX(TestMax[RevAnnual])

 image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




OK! I've got it!

 

So the solution here is a compilation of what @PattemManohar and @Fcoatis proposed. And here is what I did:

 

1. Created a new DAX table, where I put all the data I need as Columns.

1.1. I created a table where I used DISTINCT(Customer[Customer]) formula;

1.2. I added a new column: RevAnnual = [RevAnnual], which was a measure;

1.3. I then I used the formula which @PattemManohar proposed. It took me good 2 minutes to figureout that it is Column, not Measure formula.

 

It works. Thanks everyone for the support. You're great.

OK Now I have an issue when I try to use the same approach when the values are % I try to divide the profitability % by the MAX profitability % in a column. Same scenario but not with absolute values and the result is not the one I require.

 

Any suggestions?

Please send a sample of your data and the expected result.

 

Regards

Basically the same scenario but with %

 

CustomerProfitability %Ranking
A27.40%0.61
B25.80%0.57
C16.10%0.36
D13.60%0.30
E25.00%0.56
F36.00%0.80
G18.60%0.41
H-24.90%-0.55
I33.10%0.74
J22.80%0.51
K-0.50%-0.01
L7.60%0.17
M35.40%0.79
N8.30%0.18
O22.20%0.49
P-11.20%-0.25
Q24.10%0.54
R26.10%0.58
S25.30%0.56
T13.90%0.31
U21.50%0.48
V23.90%0.53
W25.70%0.57
X26.40%0.59
Z44.90%1.00
AA18.50%0.41

Fig 2.PNG

It is not working with me. I did not mentioned something which I am sure is significant. the RevAnnual is a measure. not columnt from the table.

Hi I'm close to obtain the same result. Just a question why is this Sort column in the table you produced. Is it essential. If I remove it from your formula then it returns 1 for all of the customers.

Hi @ganchevd,

 

The sort column is not essential. Its just for a matter to sort properly the Customer name. You can remove it. Be aware that you must remove all mentions to that column in the measure I showed you.

 

Best regards.

Yes it should be that simple if the data is in one and the same table. I shall start over since there are some complications which break my formula.

 

1. The data is a direct link to SQL database with multiple tables;

2. The column Customer is a column from the table Customers, which is linked 1: many with the table Revenue;

3. The column RevAnnual is in the table Revenue and the table I showed above it is an aggregated of all the postings by Customer. Or when I presnt the data in the tablle, attached above when I chose the column customer it is something like the subtotal in Excel.

 

I am not sure if I explained it but I cannot attach the exported raw data from the ERP SQL database

LivioLanzo
Solution Sage
Solution Sage

do you want to do this in a measure or calculated column ?

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

I'd like it in measure.

should be something like this:

 

=
IF (
    HASONEVALUE ( Table[Customer] ),
    DIVIDE (
        SUM ( Table[RevAnnual] ),
        CALCULATE ( SUM ( Table[RevAnnual] )ALL ( Table[Customer] ) )
    )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Just substitute max for sum:

 

Rank =
IF(
        HASONEVALUE(Customer[Customer]),
        DIVIDE(
            SUM(Customer[RevAnnual]),
            CALCULATE(MAX(Customer[RevAnnual]);ALL(Customer[Customer]))
       )
)

Now I try to modify this formula but I cannot use MAX argument for measure or something like this:

 

 

Rank =
IF(
        HASONEVALUE(Customer[Customer]),
        DIVIDE(
            [RevAnnual],
            CALCULATE(MAX([RevAnnual]);ALL(Customer[Customer]))
       )
)

 

I'm totally stuck. Thanks everyone for the help.

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.