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:
And the bottom:
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]