Forum Discussion

DECRE83's avatar
DECRE83
Regular Visitor
1 year ago
Solved

sum measure from different cards

Hello,

 

So I have a page where I need to add certain steps on a transportation route. Each step of the route has a cost. At the end, I need a measure that sums the total of the individual steps, thus, giving me the total cost of the route.

 

 

The problem is that the measure I made is adding the total costs of all the different steps I have in my dataset, not filtering only the three steps in the specific route I selected in my slicers.

 

What can I do?

 

  • Hi  DECRE83 
    Welcome to the Microsoft Fabric Forum,

     

    Regarding the measure to sum only the selected steps for the transportation route:

     

    Since all step costs are stored in a single table, and the requirement is for the total to reflect only the steps selected through the slicers, a measure should be created that dynamically respects the current filter context.

     

    Use SUMX function :

    DAX:

    Total Selected Route Cost = 
    SUMX( VALUES(Table[StepID]), 
    CALCULATE(SUM(Table[StepCost])) )


    If steps are uniquely identified by multiple columns (category, location1,location2) adjust the measure:

    DAX:

    Total Selected Route Cost = 
    SUMX( 
    SUMMARIZE( Table, 
    Table[Category], 
    Table[Location1], 
    Table[Location2] ), 
    CALCULATE(SUM(Table[StepCost])) ) 

     

    If this information helps resolve your issue, kindly consider marking this response as the Accepted Solution, as it may assist other community members facing similar challenges.

     

    Thank you for being part of the Microsoft Fabric Community.



     

     

     

4 Replies

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi DECRE83 

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

    Thank you.

  • Deku's avatar
    Deku
    Icon for Super User rankSuper User

    If you have a disconnected table for each of the cards with fields "category", "location1" and "location2". You then have 3 measures, one per card like

     

    Calculate(

    Sum(table[step cost]),

    Treatas(

    summarize(

    disconnectedtable1,

    disconnectedtable1[category], disconnectedtable1[location1], disconnectedtable1[location2]

    ), 

    Summarize(

    Table

    Table[category],

    Table[location1],

    Table[location2]

    )

    )

     

    Then for the total, sum the 3 measures together

     

    Not sure on the structure of your model, but this kind of approach should work

  • DECRE83's avatar
    DECRE83
    Regular Visitor

    thank you for your response!

     

    The tables are not disconnected, the step costs are in a table that have the different cobinations with point a - point b - cost, point b - point c - cost.

     

    So I can“t calculate three different measures to sum the steps since the data is in one table.

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi  DECRE83 
    Welcome to the Microsoft Fabric Forum,

     

    Regarding the measure to sum only the selected steps for the transportation route:

     

    Since all step costs are stored in a single table, and the requirement is for the total to reflect only the steps selected through the slicers, a measure should be created that dynamically respects the current filter context.

     

    Use SUMX function :

    DAX:

    Total Selected Route Cost = 
    SUMX( VALUES(Table[StepID]), 
    CALCULATE(SUM(Table[StepCost])) )


    If steps are uniquely identified by multiple columns (category, location1,location2) adjust the measure:

    DAX:

    Total Selected Route Cost = 
    SUMX( 
    SUMMARIZE( Table, 
    Table[Category], 
    Table[Location1], 
    Table[Location2] ), 
    CALCULATE(SUM(Table[StepCost])) ) 

     

    If this information helps resolve your issue, kindly consider marking this response as the Accepted Solution, as it may assist other community members facing similar challenges.

     

    Thank you for being part of the Microsoft Fabric Community.