cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

Paginated report dataset from Power BI DAX query

Hello,

 

Is there anyone who created a datset in Paginated report using Power BI Dax query (from Performance Analyzer)?

 

Jess90_0-1635888600924.png

Query:

// DAX Query

DEFINE

  VAR __DS0Core =

    SELECTCOLUMNS(

      KEEPFILTERS(

        FILTER(

          KEEPFILTERS(

            SUMMARIZECOLUMNS(

              'DimLocation'[Country],

              'Action'[Control],

              "CountRowsFactAction", CALCULATE(COUNTROWS('Action'))

            )

          ),

          OR(

            NOT(ISBLANK('DimLocation'[Country])),

            NOT(ISBLANK('Action'[Control]))

          )

        )

      ),

      "'DimLocation'[Country]", 'DimLocation'[Country],

      "'FactAction'[Control]", 'Action'[Control]

    )

 

  VAR __DS0PrimaryWindowed =

    TOPN(501, __DS0Core, 'DimLocation'[Country], 1, 'Action'[Control], 1)

 

EVALUATE

  __DS0PrimaryWindowed

 

ORDER BY

  'DimLocation'[Country], 'Action'[Control]

 

My question: How can I create a parameter if I use this query? How to write a DAX code included in this query to create a parameter in paginated report? 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Use the @ symbol for a parameter and make sure it's mapped in the parameters section.

 

Here's a simplified example based on your query:

DEFINE
    VAR CountryFilter = TREATAS ( { @Country }, 'DimLocation'[Country] )
EVALUATE
SUMMARIZECOLUMNS (
    'DimLocation'[Country],
    'Action'[Control],
    CountryFilter,
    "CountRowsFactAction", CALCULATE ( COUNTROWS ( 'Action' ) )
)

 

More detail in my answer here: https://stackoverflow.com/questions/68820105

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@AlexisOlson thanks for the quick solution.

AlexisOlson
Super User
Super User

Use the @ symbol for a parameter and make sure it's mapped in the parameters section.

 

Here's a simplified example based on your query:

DEFINE
    VAR CountryFilter = TREATAS ( { @Country }, 'DimLocation'[Country] )
EVALUATE
SUMMARIZECOLUMNS (
    'DimLocation'[Country],
    'Action'[Control],
    CountryFilter,
    "CountRowsFactAction", CALCULATE ( COUNTROWS ( 'Action' ) )
)

 

More detail in my answer here: https://stackoverflow.com/questions/68820105

Anonymous
Not applicable

@AlexisOlson thanks for the quick solution. 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors