Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Keeping null values in aggregation table

I"m working on a report to identify if resources have been committed correctly to various projects. The demand hours, commit hours, and constrained hours (gap hours) are on three different rows in the data set and I'm trying to consolidation all of them to 1 row. I created a Y\N flag to identify if the value in the committed column is either 0 or null. the data set looks like this:

 

WorkCategoryValueProject NameIDResourceRoleValueResourceNameIdTaskDetailTier34OrgIdMonthCatHoursDateDemand HrsCommit HrsBlankCommitFlag
Project35Electrical Engineer 2 TTS Analyst11AugGap488/1/202000N
Project35Electrical Engineer 2 TTS Analyst11Aug 488/1/2020480N
Project35Electrical Engineer 2 TTS Analyst11AugCommit 8/1/20200 Y

 

 

           

 

I aggregated the data set, but I'm generating two rows where there should be only one, it appears as follows:

WorkCategoryValueProjectNameIdResourceRoleValueResourceNameIdTaskDetailDateBlankCommitFlagDemand HrsCommit Hrs
Project35Electrical Engineer 2 TTS Analyst8/1/2020N480
Project35Electrical Engineer 2 TTS Analyst8/1/2020Y0 

 

I'm trying to find a way to replace the 0 values with null so I can consolidate the aggregated table into 1 row. I'm not sure how to do this and could use some help, 

 

ixdutt

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous 

    I build the same table as yours to have a test.

    Just like mwegener replied before you when you summarize ,you dont need to add the BlankCommitFlag.

    I build Measure to achieve your goal.

    'AGG_REsource Request =
    
    VAR _MAXDH =
    
        MAXX (
    
            FILTER (
    
                ALL ( 'Table' ),
    
                'Table'[Project NameID] = MAX ( 'Table'[Project NameID] )
    
            ),
    
            'Table'[Demand Hrs]
    
        )
    
    VAR _MAXGH =
    
        MAXX (
    
            FILTER (
    
                ALL ( 'Table' ),
    
                'Table'[Project NameID] = MAX ( 'Table'[Project NameID] )
    
            ),
    
            'Table'[Gap Hours]
    
        )
    
    VAR _MAXCS =
    
        MAXX (
    
            FILTER (
    
                ALL ( 'Table' ),
    
                'Table'[Project NameID] = MAX ( 'Table'[Project NameID] )
    
            ),
    
            'Table'[Commit Hrs]
    
        )
    
    RETURN
    
        SUMMARIZE (
    
            'Table',
    
            [WorkCategoryValue],
    
            [Project NameID],
    
            'Table'[ResourceRoleValue],
    
            'Table'[ResourceNameId],
    
            'Table'[TaskDetail],
    
            'Table'[Date],
    
            "Demand Hrs", _MAXDH,
    
            "Gap Hours", _MAXGH,
    
            "Commit Hrs", _MAXCS
    
        )

    Result:

    You can download the pbix file from this link: Keeping null values in aggregation table

     

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

     

    Best Regards,

    Rico Zhou

6 Replies

  • Anonymous , it not coming in one row because of CommitFlag, it has value Y and N. Take Max for that?

     

    Typically Numbers has default aggregation as a sum. That should add up to one row.  Or use some aggregation for Demand Hrs ,Commit Hrs

    • Anonymous's avatar
      Anonymous
      Not applicable

      Amit, 

       

      Thanks for your reply, but does the MAX() function apply to Y\N values in a column? I thought the function only applies to numeric values only. 

       

      ixdutt

  • mwegener's avatar
    mwegener
    Most Valuable Professional

    Hi Anonymous,

     

    how you aggregated the data?

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      mwegener, 

       

      I first added the following column to the source data set to identify null values in the data set (I realize that null values are replaced by 0 values in aggregation tables):

      BlankCommitFlag = IF(ISBLANK([Commit Hours]), "Y", "N"

       

      Then in the Data View, Modelling > Create Table

       

      'AGG_REsource Request = SUMMARIZE('FACT_ResourceRequestList',[WorkCategoryValue],[ProjectNameId],[Tier34OrgId],' etc. to build out the aggregated table. 

       

      I hope that helps, 

       

      ixdutt

      • mwegener's avatar
        mwegener
        Most Valuable Professional

        Hi Anonymous 

         

        do not include the column BlankCommitFlag in your SUMMARIZE

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    I build the same table as yours to have a test.

    Just like mwegener replied before you when you summarize ,you dont need to add the BlankCommitFlag.

    I build Measure to achieve your goal.

    'AGG_REsource Request =
    
    VAR _MAXDH =
    
        MAXX (
    
            FILTER (
    
                ALL ( 'Table' ),
    
                'Table'[Project NameID] = MAX ( 'Table'[Project NameID] )
    
            ),
    
            'Table'[Demand Hrs]
    
        )
    
    VAR _MAXGH =
    
        MAXX (
    
            FILTER (
    
                ALL ( 'Table' ),
    
                'Table'[Project NameID] = MAX ( 'Table'[Project NameID] )
    
            ),
    
            'Table'[Gap Hours]
    
        )
    
    VAR _MAXCS =
    
        MAXX (
    
            FILTER (
    
                ALL ( 'Table' ),
    
                'Table'[Project NameID] = MAX ( 'Table'[Project NameID] )
    
            ),
    
            'Table'[Commit Hrs]
    
        )
    
    RETURN
    
        SUMMARIZE (
    
            'Table',
    
            [WorkCategoryValue],
    
            [Project NameID],
    
            'Table'[ResourceRoleValue],
    
            'Table'[ResourceNameId],
    
            'Table'[TaskDetail],
    
            'Table'[Date],
    
            "Demand Hrs", _MAXDH,
    
            "Gap Hours", _MAXGH,
    
            "Commit Hrs", _MAXCS
    
        )

    Result:

    You can download the pbix file from this link: Keeping null values in aggregation table

     

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

     

    Best Regards,

    Rico Zhou