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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cathoms
Responsive Resident
Responsive Resident

Creating new table: Too many rows error

Hi. I'm trying to create a new table for use in a dynamic legend slicer and am getting the following error: "<pi>The resultset of a query to external data source has exceeded the maximums allowed size of '1000000' rows.</pi>".

 

I don't understand why this is happening. Shouldn't the resulting table contain only as many rows as categories I am using? Below is a screenshot showing all 24 of the fields I want in my LegendCategories table. Text highlighted in yellow are table names in the data model and items outlined in red are the field/column names.

 

cathoms_1-1656350841026.png

 

And here is the DAX for the table with error message:

cathoms_2-1656350893931.png

 

For ease of reading, here is the DAX code itself:

 

LegendCategories = 
UNION(
    SELECTCOLUMNS(
        PatientDim,
        "Category", PatientDim[RaceCategory1],
        "Field", "Race Category"
    ),
    SELECTCOLUMNS(
        PatientDim,
        "Category", PatientDim[RaceCategory2],
        "Field", "Race"
    ),
    SELECTCOLUMNS(
        PatientDim,
        "Category", PatientDim[Sex],
        "Field", "Sex"
    ),
    SELECTCOLUMNS(
        CovidVaccinationStatusFact,
        "Category", CovidVaccinationStatusFact[AgeGroup 1],
        "Field", "Age Group"
    ),
    SELECTCOLUMNS(
        CovidVaccinationStatusFact,
        "Category", CovidVaccinationStatusFact[CovidVaccinated],
        "Field", "Vaccination Status"
    ),
    SELECTCOLUMNS(
        CovidVaccinationStatusFact,
        "Category", CovidVaccinationStatusFact[Booster],
        "Field", "Booster Status"
    )
)

 

 

My expected output:

CategoryField
FemaleSex
MaleSex
OtherSex
BIPOCRace Category
UnknownRace Category
WhiteRace Category
Not VaccinatedVaccination Status
VaccinatedVaccination Status
BoosterBooster Status
No BoosterBooster Status

etc.

Am I doing something wrong or just misunderstanding how this works?

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@cathoms you are using DQ and the intermediate result exceeding the 1M rows.
I guess patientdim has a lot of rows.
Maybe try to change the code to:

 

LegendCategories =
UNION (
    SELECTCOLUMNS (
        VALUES ( PatientDim[RaceCategory1] ),
        "Category", PatientDim[RaceCategory1],
        "Field", "Race Category"
    ),
    SELECTCOLUMNS (
        VALUES ( PatientDim[RaceCategory2] ),
        "Category", PatientDim[RaceCategory2],
        "Field", "Race"
    ),
    SELECTCOLUMNS (
        VALUES ( PatientDim[Sex] ),
        "Category", PatientDim[Sex],
        "Field", "Sex"
    ),
    SELECTCOLUMNS (
        VALUES ( CovidVaccinationStatusFact[AgeGroup 1] ),
        "Category", CovidVaccinationStatusFact[AgeGroup 1],
        "Field", "Age Group"
    ),
    SELECTCOLUMNS (
        VALUES ( CovidVaccinationStatusFact[CovidVaccinated] ),
        "Category", CovidVaccinationStatusFact[CovidVaccinated],
        "Field", "Vaccination Status"
    ),
    SELECTCOLUMNS (
        VALUES ( CovidVaccinationStatusFact[Booster] ),
        "Category", CovidVaccinationStatusFact[Booster],
        "Field", "Booster Status"
    )
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

3 REPLIES 3
cathoms
Responsive Resident
Responsive Resident

Oh, great idea! Works perfectly, thanks!

SpartaBI
Community Champion
Community Champion

@cathoms my pleasure 🙂
Hey, check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. 
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

SpartaBI
Community Champion
Community Champion

@cathoms you are using DQ and the intermediate result exceeding the 1M rows.
I guess patientdim has a lot of rows.
Maybe try to change the code to:

 

LegendCategories =
UNION (
    SELECTCOLUMNS (
        VALUES ( PatientDim[RaceCategory1] ),
        "Category", PatientDim[RaceCategory1],
        "Field", "Race Category"
    ),
    SELECTCOLUMNS (
        VALUES ( PatientDim[RaceCategory2] ),
        "Category", PatientDim[RaceCategory2],
        "Field", "Race"
    ),
    SELECTCOLUMNS (
        VALUES ( PatientDim[Sex] ),
        "Category", PatientDim[Sex],
        "Field", "Sex"
    ),
    SELECTCOLUMNS (
        VALUES ( CovidVaccinationStatusFact[AgeGroup 1] ),
        "Category", CovidVaccinationStatusFact[AgeGroup 1],
        "Field", "Age Group"
    ),
    SELECTCOLUMNS (
        VALUES ( CovidVaccinationStatusFact[CovidVaccinated] ),
        "Category", CovidVaccinationStatusFact[CovidVaccinated],
        "Field", "Vaccination Status"
    ),
    SELECTCOLUMNS (
        VALUES ( CovidVaccinationStatusFact[Booster] ),
        "Category", CovidVaccinationStatusFact[Booster],
        "Field", "Booster Status"
    )
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors