Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Anonymous
Not applicable

Create new table using another table

Hi, I am trying to groupby a table and want to create new table from that:

anbose_0-1703709605426.png

 


From the above dummy tableI want to create  the below table 'AggregatedTable', "NoofTest" is count of all rows coming after grouping, "PassTests" column will contain count of those row whenever TABLENAME['DIFFERENCE'] will be zero. I am getting error for the below code, how to resolve it?
AggregatedTable =

GROUPBY( TABLENAME, TABLENAME[Source], TABLENAME[KPI],

 "NoOfTests", COUNTX(CURRENTGROUP(), COUNTROWS(TABLENAME)), "PassTests",COUNTX(CALCULATETABLE(TABLENAME,TABLENAME[Difference]=0),COUNTROWS(TABLENAME)) )

1 ACCEPTED SOLUTION
v-weiyan1-msft
Community Support
Community Support

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.

vweiyan1msft_0-1703754743320.png

 

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.

View solution in original post

4 REPLIES 4
v-weiyan1-msft
Community Support
Community Support

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.

vweiyan1msft_0-1703754743320.png

 

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.

Anonymous
Not applicable

It worked! Thanks

ryan_mayu
Super User
Super User

@Anonymous 

what's the expected output based on the sample data you provided?

could you pls provide a table of output as well?

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




jjrand
Helper I
Helper I

Hi, can you please post your data in a way that's easy to copy and paste? Your question would be more likely to get answered.

 

See here

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...0

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.