Forum Discussion

LanrexTee's avatar
LanrexTee
Frequent Visitor
6 years ago
Solved

Duplicating Rows in a Table in Modelling Tab

Hello Team,   I have a Table (Table 1) with sample data below.   I would like to create another Table (Table2) from it with repeated rows based on RowCount Column below. Note that Row with 'Pend...
  • amitchandak's avatar
    amitchandak
    6 years ago

    In my formula.

    Table 2 , I removed pending and added data. In table 3, I removed pending, Also check if pending exists, Hope you taken care of that in your formula, Or in visualization, put a visual level filter to remove pending.

     

    Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
    Thanks. My Recent Blog -
    https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
    https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
    https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

  • LanrexTee's avatar
    LanrexTee
    6 years ago

    amitchandak 

    Thanks a lot for your help....

    I think the source of that error is the line I highlighted in red colour in the Union  where no filter is applied to remove the 'Pending'.

    I did some modifications to that and it worked fine.

     

    Table 3 = UNION(SUMMARIZE(duplicaterow,duplicaterow[Approval Month],"New Column",FIRSTNONBLANK(duplicaterow[Approval Month],""),"Row Count",sum(duplicaterow[RowCount ])),
    SUMMARIZE('Table 2','Table 2'[New Column],'Table 2'[Approval Month],'Table 2'[Row Count])

     

    So my modifications and final code by adding FILTER  with CALCULATETABLE is as per below :

     

    Table 3 =
     UNION(
    CALCULATETABLE(
        SUMMARIZE(duplicaterow,duplicaterow[Approval Month],"New Column",FIRSTNONBLANK(duplicaterow[Approval Month],""),"Row Count",sum(duplicaterow[RowCount])),
                FILTER(duplicaterow,duplicaterow[Approval Month]<>"Pending")),
    SUMMARIZE('Table 2','Table 2'[New Column],'Table 2'[Approval Month],'Table 2'[Row Count])
    )

     

     

    Regards