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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Add up Total cell value into List using Mcode

Hi,

 

 

I create this List as below from my data source and hope to add 'Total' value in a row which will be for 5G + LTE_M.

Then I could make below calculation for Total vs 5G or Total vs LTE_M.

Is there any Mcode I can forcely add up 'Total' value into automacically created List? 

*there will be more unique value which is unknown now apart from 5G and LTE_M in the future so I cannot create a table manually.

 

 

Total vs =
var _legend = SELECTEDVALUE('Total'[Frequency])
var _result = IF(_legend="Total", CALCULATE('Sum of XXXXXX ,ALL('Delivery & Fault Trend'[Frequency])), CALCULATE('Delivery & Fault Trend'[Sum of XXXXXX], 'Delivery & Fault Trend'[Frequency]=_legend))
return  _result
 
 
 

jeongkim_0-1736394364363.png

my desired output is 

1. Total

2. 5G

3. LTE_M

 

 

FYI,

let
Source = Table.Combine({#"TOSS service PO_master - Previous Backup Data", #"TOSS service PO_master - Current Weekly Data"}),
Frequency = Source[Frequency],
#"Removed Duplicates" = List.Distinct(Frequency)
in
#"Removed Duplicates"

1 ACCEPTED SOLUTION

This is based on your original query

let
Source = Table.Combine({#"TOSS service PO_master - Previous Backup Data", #"TOSS service PO_master - Current Weekly Data"}),
Frequency = Source[Frequency],
#"Removed Duplicates" = List.Distinct(Frequency),
#"Added Total row" = List.Combine({"Total"}, #"Removed Duplicates")
in
#"Added Total row"




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

+I've succeeded creating as below, just pls suggest if there is any better way. 

 

 

jeongkim_0-1736395225629.png

let
Source = Table.Combine({#"TOSS service PO_master - Previous Backup Data", #"TOSS service PO_master - Current Weekly Data"}),
Frequency = Source[Frequency],
#"Removed Duplicates" = List.Distinct(Frequency),
#"Converted to Table" = Table.FromList(#"Removed Duplicates", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each "Total"),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Added Custom", {}, "Attribute", "Value"),
#"Removed Duplicates1" = Table.Distinct(#"Unpivoted Columns", {"Value"}),
#"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates1",{"Attribute"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Frequency"}})
in
#"Renamed Columns"

This is based on your original query

let
Source = Table.Combine({#"TOSS service PO_master - Previous Backup Data", #"TOSS service PO_master - Current Weekly Data"}),
Frequency = Source[Frequency],
#"Removed Duplicates" = List.Distinct(Frequency),
#"Added Total row" = List.Combine({"Total"}, #"Removed Duplicates")
in
#"Added Total row"




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @Anonymous 

 

Try this:

// Combine the text value "Total" with a distinct list of elements from the list "Frequency".
List.Combine(
    {"Total"},          // A single-element list containing the text value "Total".
    List.Distinct(      // Remove duplicate elements from the list "Frequency".
        Frequency       // The list from which duplicates are removed.
    )
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.