Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Sum Measure from a aggregated summarize column

Hi all,

 

I know this could be a basic question, but as I'm new on this Dax I would like to ear from you a solution for my question :

I have the follow : 

    SUMMARIZECOLUMNS(
            FTPlacementHours[JobId],
            FTPlacementHours[PotentialHours],
            dimCalendar[WeekEndingDateFriday],
            KEEPFILTERS(TREATAS({"2024-09-06", "2024-09-13", "2024-09-20", "2024-09-27"},dimCalendar[WeekEndingDateFriday])),
            KEEPFILTERS(TREATAS({95976},FTPlacementHours[JobId]))           
    )

My result is : 

JobId   Potentialhours  WeekEndingDateFriday
95976  | 10.000000        | 2024-09-06
95976  | 10.000000        | 2024-09-13
95976  | 10.000000        | 2024-09-20

95976  |  10.000000       | 2024-09-27

 

My Question : How I can return the sum of all Potentialhours to present in a card in PBI?

 

I will appreciate some help !

Thanks

Pedro

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi , My appologise, 

    My base data is for one use case jobid  95676

     

    JobId  | Potentialhours | Session_StartDate | WeekEndingDateFriday
    95976 | 10.000000        | 2024-09-16           | 2024-09-20
    95976 | 10.000000        | 2024-09-13           | 2024-09-13
    95976 | 10.000000        | 2024-09-17           | 2024-09-20
    95976 | 10.000000        | 2024-09-09           | 2024-09-13
    95976 | 10.000000        | 2024-09-18           | 2024-09-20
    95976 | 10.000000        | 2024-09-04           | 2024-09-06
    95976 | 10.000000        | 2024-09-12           | 2024-09-13
    95976 | 10.000000        | 2024-09-26           | 2024-09-27

    Then I need to Gregate this data per week

     

    JobId  | Potentialhours | WeekEndingDateFriday

    95976 | 10.000000        | 2024-09-20

    95976 | 10.000000        | 2024-09-13

    95976 | 10.000000        | 2024-09-06

    95976 | 10.000000        | 2024-09-27

     

    At the End I would like to get a card with a measure that gives me 40 as total or a total of all jobs ID 

     

8 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Try:

    Measure = 
     SUMX(
        SUMMARIZECOLUMNS(
                FTPlacementHours[JobId],
                FTPlacementHours[PotentialHours],
                dimCalendar[WeekEndingDateFriday],
                KEEPFILTERS(TREATAS({"2024-09-06", "2024-09-13", "2024-09-20", "2024-09-27"},dimCalendar[WeekEndingDateFriday])),
                KEEPFILTERS(TREATAS({95976},FTPlacementHours[JobId]))           
        ),
        [Potentialhours]
      )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Is great ! Thank you for your quick answare. But when I remove the filter gives me complete different values. this is what block me! 

      I mean when I remove the  line  KEEPFILTERS(TREATAS({95976},FTPlacementHours[JobId])) , because I was testing one unique case with jobid 95976. and with dates as filter

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Thank you for reaching out to the Microsoft Fabric Community.

     

    To get the correct total in a card (e.g., 10 per week across 4 weeks = 40), you'll want to avoid double-counting session rows and instead aggregate by week. Please try the following measure:

    TotalPotentialHours :=
    SUMX(
        SUMMARIZE(
            FTPlacementHours,
            FTPlacementHours[JobId],
            dimCalendar[WeekEndingDateFriday],
            "WeeklyPotential", MAX(FTPlacementHours[PotentialHours])
        ),
        [WeeklyPotential]
    )
    

    This groups by JobId and WeekEndingDateFriday, takes one PotentialHours value per week (using MAX), and sums across all weeks.

    If you need to apply filters like specific dates or JobId, you can adapt it with SUMMARIZECOLUMNS and TREATAS as you were doing earlier.

     

    I hope this could reslove your issue, if you need any further assistance, feel free to reach out.

    If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

     

    Thank you. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous   ,

      I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


      Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi @pjm   ,

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous  ,

     

    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.