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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Saxon202202
Helper III
Helper III

Summarise sum and Max in new table

Hi,
I have following columns are in data table Order, Item, Code, Qty, Country code and Tax Code.
I am trying to summarise the sum of qty each order, item and code, based on the sum of qty, I am trying to get the max qty according to the item, code by using new table. 
Also, in the new table I want get the most frequency of country and tax code.
Can you please suggested DAX code-New Table, Measure and Power Query options. 

Saxon202202_0-1678391232200.png

 

https://www.dropbox.com/s/5w2hrl2zp5s6dvx/Summarise.pbix?dl=0

 

15 REPLIES 15
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1678395134542.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hi, Thanks for your reply and help. 

Can you please advise how can I get the same result by using new table option (DAX) and power query as well. 

I don't opt for PQ to do calculation.

CNENFRNL_0-1678467909179.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL, @andhiii079845,

 

Hi, I created sum of qty column in data table by using the following dax Sum Of Qty = Calculate(sum(data([qty]),

filter(data,

data[item] =earlier(data[item]) & &

data[order] =earlier(data[order])),

allexpect(data, data[item]))

IMG_20230311_104028.jpg

Now I have sum of qty row level and then I created new table by using this DAX code,

Table2 =

summarize(data),

data[item], data[code],

"Max Qty", Max(data[SumOfQty]),

"Country Code" Max(data[contry code]),

"Tax Code", Max(data[Tax Code]))

IMG_20230311_104218.jpg

attached snapshot for your reference. 

I got the results (Snapshot table 2)by creating additional columns in Data Table but unable to apply the no blanks conditions in summary table for country code and tax code columns.

 

I want the same result (Table 2 snapshot) without maintain the additional columns in Data Table also apply non blanks conditions in summary table. 

@CNENFRNL, Thanks for your reply. How can I incuding the actual data column instead using measure column in summary table? Please. 

 

Y

andhiii079845
Solution Sage
Solution Sage

How you define most frequency in the desired table?





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

Proud to be a Super User!




@andhiii079845,

Most repeated value according to the item. 

Try this. Thank you for the good prepartion: good example with a file, a clear presentation of the result! 🙂
 

Table =


VAR _tabcountry = TOPN(1,FILTER(SUMMARIZE(data,DATA[Item],DATA[Country Code],"_countcountry",count(DATA[Country Code])),DATA[Country Code]<>BLANK()),[_countcountry])
VAR _tax = TOPN(1,FILTER(SUMMARIZE(data,DATA[Item],DATA[Tax Code],"_counttax",count(DATA[Tax Code])),DATA[Tax Code]<>BLANK()),[_counttax])
VAR _sum = TOPN(1,SUMMARIZE(data,DATA[Order],DATA[Item],"_qty",sum(DATA[Qty])),[_qty])
RETURN NATURALINNERJOIN(NATURALINNERJOIN(_tabcountry,_tax),_sum)


andhiii079845_0-1678395459482.png





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

Proud to be a Super User!




@andhiii079845 ,
I apply your code into data table and some reason it return blanks. I don't know were it went wrong. Can you please suggest alternative solution.

Please give your data which generate blank().





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

Proud to be a Super User!




@andhiii079845, It's not working the the sample data. can you please share your output file.

https://www.dropbox.com/s/5w2hrl2zp5s6dvx/Summarise.pbix?dl=0

I create a new table, insert the code and go to data view:

Summarise.pbix





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

Proud to be a Super User!




@andhiii079845 ,
Thanks for your reply.
I added coulple of addtional line and it's not working.
Herewith attached file for your reference. 
https://www.dropbox.com/s/2wzxhrx9krn2t3z/Summarise%20%283%29.pbix?dl=0

@andhiii079845, Thanks for your reply and help. I will check your formula and update the feedback.

I am sorry, I give up. I try to find a sustianable solution (my first not work I see) but I think after nearly one hour that this problem has to be think bigger? Divide the table in smaller tables and build a data model? 





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

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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