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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
apmulhearn
Helper III
Helper III

"Enter a valid JSON" error Power Automate when I run JSON query against dataset

Hello,

I

I am building a Flow in Power Automate which seeks to query a table visualization published in Power BI Premium and generate a csv from that data. However, I keep receiving an error message which reads "Enter a valid JSON." My method is below.

 

First, I've obtained the proper visual JSON query by
1. Opening report in Desktop

2. Selecting Visual

3. Selecting Performance Analyzer

4. Selecting Record

5. Selecting Refresh Visuals

6. Hitting Stop

7. Copying the DAX from the visual I want to copy (a basic table)

 

When I paste the DAX code into Power Automate, I receive an error which reads "Enter a Valid JSON."
The resulting DAX code is pasted at the bottom of this post.

Here is the top of my flow:

apmulhearn_0-1686311718602.png


And the bottom:

apmulhearn_1-1686311743855.png

 


Here is the query I am entering which results from my Desktop file:

// DAX Query
DEFINE
VAR __DS0FilterTable = 
FILTER(
KEEPFILTERS(VALUES('P15 Guest'[Booking])),
NOT(SEARCH("DO NOT USE", 'P15 Guest'[Booking], 1, 0) >= 1)
)
 
VAR __DS0FilterTable2 = 
FILTER(KEEPFILTERS(VALUES('P15 Guest'[Depart Age])), 'P15 Guest'[Depart Age] >= 18)
 
VAR __DS0FilterTable3 = 
FILTER(
KEEPFILTERS(
VALUES('P15 Guest'[Start Date (Departure) (Departure)])
),
AND(
'P15 Guest'[Start Date (Departure) (Departure)] >= DATE(2023, 6, 9),
'P15 Guest'[Start Date (Departure) (Departure)] < DATE(2026, 3, 5)
)
)
 
VAR __DS0FilterTable4 = 
TREATAS({"Booked"}, 'P15 Guest'[Status Reason])
 
VAR __DS0FilterTable5 = 
FILTER(
KEEPFILTERS(VALUES('P15 Guest'[LookupHouseholdID])),
NOT('P15 Guest'[LookupHouseholdID] IN {BLANK()})
)
 
VAR __DS0Core = 
SELECTCOLUMNS(
KEEPFILTERS(
FILTER(
KEEPFILTERS(
SUMMARIZECOLUMNS(
'P15 Guest'[Booking],
'P15 Guest'[Status Reason],
'P15 Guest'[First Payment Date (Booking) (Booking)],
'P15 Guest'[Owner (Booking) (Booking)],
'P15 Guest'[Booking #],
'P15 Guest'[Departure Code (Departure) (Departure)],
'P15 Guest'[Parent Booking (Booking) (Booking)],
'P15 Guest'[Travel Agency (Booking) (Booking)],
'P15 Guest'[Travel Agency Network (Booking) (Booking)],
'P15 Guest'[Travel Agent (Booking) (Booking)],
'P15 Guest'[Primary Email (Owning User) (User)],
'P15 Contact List'[Salutation (Household) (Household)],
'P15 Guest'[LookupHouseholdID],
'P15 Guest'[LookupTripType],
'Trips'[Trip Name],
'P15 Guest'[Client (Booking) (Booking)],
'P15 Guest'[Address 2: City (Contact) (Contact)],
'P15 Guest'[Address 2: Country/Region (Contact) (Contact)],
'P15 Guest'[Address 2: State/Province (Contact) (Contact)],
'P15 Guest'[Address 2: Street 1 (Contact) (Contact)],
'P15 Guest'[Address 2: Street 2 (Contact) (Contact)],
'P15 Guest'[Start Date (Departure) (Departure)],
'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)],
'P15 Guest'[Departure ID (Departure) (Departure)],
'P15 Guest'[Email (Contact) (Contact)],
'P15 Guest'[Household (Contact) (Contact)],
'P15 Contact List'[Address 2],
'P15 Contact List'[Address for PreTour],
'HouseholdTable Ref of Contact'[ Name (Household) (Household)],
'P15 Guest'[Departure],
__DS0FilterTable,
__DS0FilterTable2,
__DS0FilterTable3,
__DS0FilterTable4,
__DS0FilterTable5,
"CountRowsP15_Guest", CALCULATE(COUNTROWS('P15 Guest'))
)
),
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
OR(
NOT(ISBLANK('P15 Guest'[Booking])),
NOT(ISBLANK('P15 Guest'[Status Reason]))
),
NOT(
ISBLANK('P15 Guest'[First Payment Date (Booking) (Booking)])
)
),
NOT(
ISBLANK('P15 Guest'[Owner (Booking) (Booking)])
)
),
NOT(ISBLANK('P15 Guest'[Booking #]))
),
NOT(
ISBLANK('P15 Guest'[Departure Code (Departure) (Departure)])
)
),
NOT(
ISBLANK('P15 Guest'[Parent Booking (Booking) (Booking)])
)
),
NOT(
ISBLANK('P15 Guest'[Travel Agency (Booking) (Booking)])
)
),
NOT(
ISBLANK('P15 Guest'[Travel Agency Network (Booking) (Booking)])
)
),
NOT(
ISBLANK('P15 Guest'[Travel Agent (Booking) (Booking)])
)
),
NOT(
ISBLANK('P15 Guest'[Primary Email (Owning User) (User)])
)
),
NOT(
ISBLANK('P15 Contact List'[Salutation (Household) (Household)])
)
),
NOT(ISBLANK('P15 Guest'[LookupHouseholdID]))
),
NOT(ISBLANK('P15 Guest'[LookupTripType]))
),
NOT(ISBLANK('Trips'[Trip Name]))
),
NOT(
ISBLANK('P15 Guest'[Client (Booking) (Booking)])
)
),
NOT(
ISBLANK('P15 Guest'[Address 2: City (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Address 2: Country/Region (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Address 2: State/Province (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Address 2: Street 1 (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Address 2: Street 2 (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Start Date (Departure) (Departure)])
)
),
NOT(
ISBLANK('P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Departure ID (Departure) (Departure)])
)
),
NOT(
ISBLANK('P15 Guest'[Email (Contact) (Contact)])
)
),
NOT(
ISBLANK('P15 Guest'[Household (Contact) (Contact)])
)
),
NOT(ISBLANK('P15 Contact List'[Address 2]))
),
NOT(ISBLANK('P15 Contact List'[Address for PreTour]))
),
NOT(
ISBLANK('HouseholdTable Ref of Contact'[ Name (Household) (Household)])
)
),
NOT(ISBLANK('P15 Guest'[Departure]))
)
)
),
"'P15 Guest'[Booking]", 'P15 Guest'[Booking],
"'P15 Guest'[Status Reason]", 'P15 Guest'[Status Reason],
"'P15 Guest'[First Payment Date (Booking) (Booking)]", 'P15 Guest'[First Payment Date (Booking) (Booking)],
"'P15 Guest'[Owner (Booking) (Booking)]", 'P15 Guest'[Owner (Booking) (Booking)],
"'P15 Guest'[Booking #]", 'P15 Guest'[Booking #],
"'P15 Guest'[Departure Code (Departure) (Departure)]", 'P15 Guest'[Departure Code (Departure) (Departure)],
"'P15 Guest'[Parent Booking (Booking) (Booking)]", 'P15 Guest'[Parent Booking (Booking) (Booking)],
"'P15 Guest'[Travel Agency (Booking) (Booking)]", 'P15 Guest'[Travel Agency (Booking) (Booking)],
"'P15 Guest'[Travel Agency Network (Booking) (Booking)]", 'P15 Guest'[Travel Agency Network (Booking) (Booking)],
"'P15 Guest'[Travel Agent (Booking) (Booking)]", 'P15 Guest'[Travel Agent (Booking) (Booking)],
"'P15 Guest'[Primary Email (Owning User) (User)]", 'P15 Guest'[Primary Email (Owning User) (User)],
"'P15 Contact List'[Salutation (Household) (Household)]", 'P15 Contact List'[Salutation (Household) (Household)],
"'P15 Guest'[LookupHouseholdID]", 'P15 Guest'[LookupHouseholdID],
"'P15 Guest'[LookupTripType]", 'P15 Guest'[LookupTripType],
"'Trips'[Trip Name]", 'Trips'[Trip Name],
"'P15 Guest'[Client (Booking) (Booking)]", 'P15 Guest'[Client (Booking) (Booking)],
"'P15 Guest'[Address 2: City (Contact) (Contact)]", 'P15 Guest'[Address 2: City (Contact) (Contact)],
"'P15 Guest'[Address 2: Country/Region (Contact) (Contact)]", 'P15 Guest'[Address 2: Country/Region (Contact) (Contact)],
"'P15 Guest'[Address 2: State/Province (Contact) (Contact)]", 'P15 Guest'[Address 2: State/Province (Contact) (Contact)],
"'P15 Guest'[Address 2: Street 1 (Contact) (Contact)]", 'P15 Guest'[Address 2: Street 1 (Contact) (Contact)],
"'P15 Guest'[Address 2: Street 2 (Contact) (Contact)]", 'P15 Guest'[Address 2: Street 2 (Contact) (Contact)],
"'P15 Guest'[Start Date (Departure) (Departure)]", 'P15 Guest'[Start Date (Departure) (Departure)],
"'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)]", 'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)],
"'P15 Guest'[Departure ID (Departure) (Departure)]", 'P15 Guest'[Departure ID (Departure) (Departure)],
"'P15 Guest'[Email (Contact) (Contact)]", 'P15 Guest'[Email (Contact) (Contact)],
"'P15 Guest'[Household (Contact) (Contact)]", 'P15 Guest'[Household (Contact) (Contact)],
"'P15 Contact List'[Address 2]", 'P15 Contact List'[Address 2],
"'P15 Contact List'[Address for PreTour]", 'P15 Contact List'[Address for PreTour],
"'HouseholdTable Ref of Contact'[ Name (Household) (Household)]", 'HouseholdTable Ref of Contact'[ Name (Household) (Household)],
"'P15 Guest'[Departure]", 'P15 Guest'[Departure]
)
 
VAR __DS0PrimaryWindowed = 
TOPN(
501,
__DS0Core,
'P15 Guest'[Client (Booking) (Booking)],
1,
'P15 Guest'[Booking],
1,
'P15 Guest'[Status Reason],
1,
'P15 Guest'[First Payment Date (Booking) (Booking)],
1,
'P15 Guest'[Owner (Booking) (Booking)],
1,
'P15 Guest'[Booking #],
1,
'P15 Guest'[Departure Code (Departure) (Departure)],
1,
'P15 Guest'[Parent Booking (Booking) (Booking)],
1,
'P15 Guest'[Travel Agency (Booking) (Booking)],
1,
'P15 Guest'[Travel Agency Network (Booking) (Booking)],
1,
'P15 Guest'[Travel Agent (Booking) (Booking)],
1,
'P15 Guest'[Primary Email (Owning User) (User)],
1,
'P15 Contact List'[Salutation (Household) (Household)],
1,
'P15 Guest'[LookupHouseholdID],
1,
'P15 Guest'[LookupTripType],
1,
'Trips'[Trip Name],
1,
'P15 Guest'[Address 2: City (Contact) (Contact)],
1,
'P15 Guest'[Address 2: Country/Region (Contact) (Contact)],
1,
'P15 Guest'[Address 2: State/Province (Contact) (Contact)],
1,
'P15 Guest'[Address 2: Street 1 (Contact) (Contact)],
1,
'P15 Guest'[Address 2: Street 2 (Contact) (Contact)],
1,
'P15 Guest'[Start Date (Departure) (Departure)],
1,
'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)],
1,
'P15 Guest'[Departure ID (Departure) (Departure)],
1,
'P15 Guest'[Email (Contact) (Contact)],
1,
'P15 Guest'[Household (Contact) (Contact)],
1,
'P15 Contact List'[Address 2],
1,
'P15 Contact List'[Address for PreTour],
1,
'HouseholdTable Ref of Contact'[ Name (Household) (Household)],
1,
'P15 Guest'[Departure],
1
)
 
EVALUATE
__DS0PrimaryWindowed
 
ORDER BY
'P15 Guest'[Client (Booking) (Booking)],
'P15 Guest'[Booking],
'P15 Guest'[Status Reason],
'P15 Guest'[First Payment Date (Booking) (Booking)],
'P15 Guest'[Owner (Booking) (Booking)],
'P15 Guest'[Booking #],
'P15 Guest'[Departure Code (Departure) (Departure)],
'P15 Guest'[Parent Booking (Booking) (Booking)],
'P15 Guest'[Travel Agency (Booking) (Booking)],
'P15 Guest'[Travel Agency Network (Booking) (Booking)],
'P15 Guest'[Travel Agent (Booking) (Booking)],
'P15 Guest'[Primary Email (Owning User) (User)],
'P15 Contact List'[Salutation (Household) (Household)],
'P15 Guest'[LookupHouseholdID],
'P15 Guest'[LookupTripType],
'Trips'[Trip Name],
'P15 Guest'[Address 2: City (Contact) (Contact)],
'P15 Guest'[Address 2: Country/Region (Contact) (Contact)],
'P15 Guest'[Address 2: State/Province (Contact) (Contact)],
'P15 Guest'[Address 2: Street 1 (Contact) (Contact)],
'P15 Guest'[Address 2: Street 2 (Contact) (Contact)],
'P15 Guest'[Start Date (Departure) (Departure)],
'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)],
'P15 Guest'[Departure ID (Departure) (Departure)],
'P15 Guest'[Email (Contact) (Contact)],
'P15 Guest'[Household (Contact) (Contact)],
'P15 Contact List'[Address 2],
'P15 Contact List'[Address for PreTour],
'HouseholdTable Ref of Contact'[ Name (Household) (Household)],
'P15 Guest'[Departure]

 

1 REPLY 1
lbendlin
Super User
Super User

Most likely your query text is too long.  You can do some severe pruning on it.  Try this version:

DEFINE
    VAR __DS0FilterTable =  FILTER(  KEEPFILTERS( VALUES( 'P15 Guest'[Booking] ) ), NOT ( SEARCH( "DO NOT USE", 'P15 Guest'[Booking], 1, 0 ) >= 1 ) )
    VAR __DS0FilterTable2 =  FILTER( KEEPFILTERS( VALUES( 'P15 Guest'[Depart Age] ) ), 'P15 Guest'[Depart Age] >= 18      )
    VAR __DS0FilterTable3 =  FILTER( KEEPFILTERS( VALUES( 'P15 Guest'[Start Date (Departure) (Departure)] ) ), 'P15 Guest'[Start Date (Departure) (Departure)] >= DATE( 2023, 6, 9 ) &&   'P15 Guest'[Start Date (Departure) (Departure)] < DATE( 2026, 3, 5 ) )
    VAR __DS0FilterTable4 =  TREATAS( { "Booked" }, 'P15 Guest'[Status Reason] )
    VAR __DS0FilterTable5 =  FILTER(  KEEPFILTERS( VALUES( 'P15 Guest'[LookupHouseholdID] ) ),  NOT ( 'P15 Guest'[LookupHouseholdID] IN { BLANK() } )        )
    EVALUATE FILTER(
                    KEEPFILTERS(
                        SUMMARIZECOLUMNS(
                            'P15 Guest'[Booking],
                            'P15 Guest'[Status Reason],
                            'P15 Guest'[First Payment Date (Booking) (Booking)],
                            'P15 Guest'[Owner (Booking) (Booking)],
                            'P15 Guest'[Booking #],
                            'P15 Guest'[Departure Code (Departure) (Departure)],
                            'P15 Guest'[Parent Booking (Booking) (Booking)],
                            'P15 Guest'[Travel Agency (Booking) (Booking)],
                            'P15 Guest'[Travel Agency Network (Booking) (Booking)],
                            'P15 Guest'[Travel Agent (Booking) (Booking)],
                            'P15 Guest'[Primary Email (Owning User) (User)],
                            'P15 Contact List'[Salutation (Household) (Household)],
                            'P15 Guest'[LookupHouseholdID],
                            'P15 Guest'[LookupTripType],
                            'Trips'[Trip Name],
                            'P15 Guest'[Client (Booking) (Booking)],
                            'P15 Guest'[Address 2: City (Contact) (Contact)],
                            'P15 Guest'[Address 2: Country/Region (Contact) (Contact)],
                            'P15 Guest'[Address 2: State/Province (Contact) (Contact)],
                            'P15 Guest'[Address 2: Street 1 (Contact) (Contact)],
                            'P15 Guest'[Address 2: Street 2 (Contact) (Contact)],
                            'P15 Guest'[Start Date (Departure) (Departure)],
                            'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)],
                            'P15 Guest'[Departure ID (Departure) (Departure)],
                            'P15 Guest'[Email (Contact) (Contact)],
                            'P15 Guest'[Household (Contact) (Contact)],
                            'P15 Contact List'[Address 2],
                            'P15 Contact List'[Address for PreTour],
                            'HouseholdTable Ref of Contact'[ Name (Household) (Household)],
                            'P15 Guest'[Departure],
                            __DS0FilterTable,
                            __DS0FilterTable2,
                            __DS0FilterTable3,
                            __DS0FilterTable4,
                            __DS0FilterTable5,
                            "CountRowsP15_Guest", CALCULATE( COUNTROWS( 'P15 Guest' ) )
                        )
                    ),
                    NOT ISBLANK( 'P15 Guest'[Booking] ) || NOT ISBLANK( 'P15 Guest'[Status Reason] ) || NOT ISBLANK( 'P15 Guest'[First Payment Date (Booking) (Booking)] )
                    || NOT ISBLANK( 'P15 Guest'[Owner (Booking) (Booking)] ) || NOT  ISBLANK( 'P15 Guest'[Booking #] ) || NOT ISBLANK( 'P15 Guest'[Departure Code (Departure) (Departure)] ) 
                    || NOT ISBLANK( 'P15 Guest'[Parent Booking (Booking) (Booking)] ) ||  NOT ISBLANK( 'P15 Guest'[Travel Agency (Booking) (Booking)] ) || NOT ISBLANK( 'P15 Guest'[Travel Agency Network (Booking) (Booking)] )
                    || NOT ISBLANK( 'P15 Guest'[Travel Agent (Booking) (Booking)] ) || NOT ISBLANK( 'P15 Guest'[Primary Email (Owning User) (User)] ) || NOT ISBLANK( 'P15 Contact List'[Salutation (Household) (Household)] ) 
                    || NOT ISBLANK( 'P15 Guest'[LookupHouseholdID] ) || NOT ISBLANK( 'P15 Guest'[LookupTripType] ) || NOT ISBLANK( 'Trips'[Trip Name] ) || NOT ISBLANK( 'P15 Guest'[Client (Booking) (Booking)] ) 
                    || NOT ISBLANK( 'P15 Guest'[Address 2: City (Contact) (Contact)] ) || NOT ISBLANK( 'P15 Guest'[Address 2: Country/Region (Contact) (Contact)] ) || NOT ISBLANK( 'P15 Guest'[Address 2: State/Province (Contact) (Contact)] ) 
                    || NOT ISBLANK( 'P15 Guest'[Address 2: Street 1 (Contact) (Contact)] ) || NOT ISBLANK( 'P15 Guest'[Address 2: Street 2 (Contact) (Contact)] ) ||NOT ISBLANK( 'P15 Guest'[Start Date (Departure) (Departure)] ) 
                    || NOT ISBLANK( 'P15 Guest'[Address 2: ZIP/Postal Code (Contact) (Contact)] ) || NOT ISBLANK( 'P15 Guest'[Departure ID (Departure) (Departure)] ) || NOT ISBLANK( 'P15 Guest'[Email (Contact) (Contact)] ) 
                    || NOT ISBLANK( 'P15 Guest'[Household (Contact) (Contact)] ) || NOT ISBLANK( 'P15 Contact List'[Address 2] ) || NOT ISBLANK( 'P15 Contact List'[Address for PreTour] ) 
                    || NOT ISBLANK( 'HouseholdTable Ref of Contact'[ Name (Household) (Household)] ) || NOT ISBLANK( 'P15 Guest'[Departure] ) 
                    
                )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors