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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
smpa01
Community Champion
Community Champion

Debugging TOJSON

Is there a reason why dynamic Max Rows in TOJSON does not work?

 

Table = {TOJSON(GENERATESERIES(1, 100000,1),-1)}

 

opposed to fully working TOCSV

Table = {TOCSV(GENERATESERIES(1, 100000,1),-1,"")}

 

 

smpa01_0-1680144406009.png

 

@AlexisOlson @bcdobbs @CNENFRNL 

 

 


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
• Week 4: View
========================
1 ACCEPTED SOLUTION

There was a bug when MaxRows is -1 that was fixed recently. You need to wait for the next Desktop release. Unfortunately dynamic expression for the MaxRows parameter isn't supported.

View solution in original post

6 REPLIES 6
AlexisOlson
Super User
Super User

It seems like a bug to me since it gives the following error rather than something more descriptive but, as PhilipTreacy mentioned, the official documentation doesn't say that it's supported.

 

AlexisOlson_0-1680192032771.png

 

Interstingly, dax.do doesn't throw an error for the query

 

EVALUATE {TOJSON(GENERATESERIES(1, 100000,1),-1)}

 

I have an application where it can become extremely useful.

I really don't care about -1. I only want an expression/dynamic expression to include all rows.

 

BTW it does not work too.

smpa01_0-1680196030784.png

@jeffrey_wang  can you shed some light if it is doable.

 


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
• Week 4: View
========================

There was a bug when MaxRows is -1 that was fixed recently. You need to wait for the next Desktop release. Unfortunately dynamic expression for the MaxRows parameter isn't supported.

PhilipTreacy
Super User
Super User

Hi @smpa01 

 

Not sure why you refer to MaxRows being dynamic - you've hardcoded -1 in that formula?

 

But I am getting an error when using a negative value for MaxRows, even though it says you can do this.  Is this the problem you are having?

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


  • I want to include all rows and by hardcoding -1, I am testing if it works on all rows. As per dax studio, a negative number should include all rows. Works for TOCSV not for TOJSON

========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
• Week 4: View
========================

Hi @smpa01 

 

As I said, I also get an error when using -1 for MaxRows.  But the official Microsoft documentation makes no mention of -1 as being a valid value

 

TOJSON function (DAX) - DAX | Microsoft Learn

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors