Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Create new table using another table

Hi, I am trying to groupby a table and want to create new table from that:   From the above dummy tableI want to create  the below table 'AggregatedTable', "NoofTest" is count of all rows c...
  • v-weiyan1-msft's avatar
    2 years ago

    Hi Anonymous ,

     

    Based on the sample and description you provided, Please try code as below.

    AggregatedTable = 
                ADDCOLUMNS(
                           GROUPBY(
                           TABLENAME,
                           TABLENAME[Source], 
                           TABLENAME[KPI],
                           "NoofTest", COUNTX(CURRENTGROUP(),COUNTROWS(TABLENAME))
                        ),
                            "PassTests", COUNTX(CALCULATETABLE(TABLENAME,TABLENAME[Difference]=0),COUNTROWS(TABLENAME)) 
                        ) 
    

    Result is as below.

     

    Best Regards,
    Yulia Yan

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