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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.