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
laurenm
Frequent Visitor

Paginated Report Query Help

This is my first real paginated report using report builder, other than a couple of column drop tables in the service. I hate it. I understand that relationships across tables do not come into the builder when using the semantic model connection but do not understand how to work around that with the DAX. 
My visual would be a matrix with the following - 
Category - Table A
SubCategory - Table B

FiscalYear - Table C
And then this measure which sums a column from Table D summarized by those - 

2YTDNetDollar =
var curryr = YEAR(TODAY())
var closmo = MONTH(TODAY())-1
RETURN
CALCULATE(SUM('Net Sales'[LineTotal]),FILTER(ALL('Net Sales'[DocDate]),YEAR('Net Sales'[DocDate])>=curryr-1 && YEAR('Net Sales'[DocDate])<=curryr && MONTH('Net Sales'[DocDate])<=closmo))


Table D is connected to Table A by a product code column, Table B by a matching subcategory column, and Table C (dates table) by the DocDate. So how do I get the right total from my measure in the paginated report? 

Thank you!

1 ACCEPTED SOLUTION
Ahmed-Elfeel
Super User
Super User

Hi @laurenm,

I hope you are doing well today ☺️❤️

 

The issue here is that DAX measures need explicit context propagation since the matrix visual doesn't automatically bridge relationships like Power BI does

 

So You have 2 Options and 1 Option If relationships exist in the model...Let's head over:

 

First Option is to use RELATEDTABLE or FILTER with relationships :

2YTDNetDollar =
VAR curryr = YEAR(TODAY())
VAR closmo = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Net Sales'[LineTotal]),
    FILTER(
        ALL('Date'[Date]),  // Use your date table here
        YEAR('Date'[Date]) >= curryr - 1 && 
        YEAR('Date'[Date]) <= curryr && 
        MONTH('Date'[Date]) <= closmo
    ),
    // explicitly bridge the relationships
    FILTER(
        'Net Sales',
        'Net Sales'[ProductCode] IN VALUES('Table A'[ProductCode]) &&
        'Net Sales'[SubCategory] IN VALUES('Table B'[SubCategory])
    )
)

 

Second Option is to use TREATAS to establish virtual Relationships:

2YTDNetDollar =
VAR curryr = YEAR(TODAY())
VAR closmo = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Net Sales'[LineTotal]),
    FILTER(
        ALL('Date'[Date]),
        YEAR('Date'[Date]) >= curryr - 1 && 
        YEAR('Date'[Date]) <= curryr && 
        MONTH('Date'[Date]) <= closmo
    ),
    TREATAS(VALUES('Table A'[ProductCode]), 'Net Sales'[ProductCode]),
    TREATAS(VALUES('Table B'[SubCategory]), 'Net Sales'[SubCategory])
)

 

The Third Option is for relationships exist in your model (CROSSFILTERS):

2YTDNetDollar =
VAR curryr = YEAR(TODAY())
VAR closmo = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Net Sales'[LineTotal]),
    FILTER(
        ALL('Date'[Date]),
        YEAR('Date'[Date]) >= curryr - 1 && 
        YEAR('Date'[Date]) <= curryr && 
        MONTH('Date'[Date]) <= closmo
    ),
    CROSSFILTER('Net Sales'[ProductCode], 'Table A'[ProductCode], BOTH),
    CROSSFILTER('Net Sales'[SubCategory], 'Table B'[SubCategory], BOTH)
)

 

  • I would recommend Option 2 Cause it is best for most paginated report scenarios and better performance and star schemas.

Let me Know if this works ☺️❤️

 

if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Ahmed-Elfeel
Super User
Super User

Hi @laurenm,

I hope you are doing well today ☺️❤️

 

The issue here is that DAX measures need explicit context propagation since the matrix visual doesn't automatically bridge relationships like Power BI does

 

So You have 2 Options and 1 Option If relationships exist in the model...Let's head over:

 

First Option is to use RELATEDTABLE or FILTER with relationships :

2YTDNetDollar =
VAR curryr = YEAR(TODAY())
VAR closmo = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Net Sales'[LineTotal]),
    FILTER(
        ALL('Date'[Date]),  // Use your date table here
        YEAR('Date'[Date]) >= curryr - 1 && 
        YEAR('Date'[Date]) <= curryr && 
        MONTH('Date'[Date]) <= closmo
    ),
    // explicitly bridge the relationships
    FILTER(
        'Net Sales',
        'Net Sales'[ProductCode] IN VALUES('Table A'[ProductCode]) &&
        'Net Sales'[SubCategory] IN VALUES('Table B'[SubCategory])
    )
)

 

Second Option is to use TREATAS to establish virtual Relationships:

2YTDNetDollar =
VAR curryr = YEAR(TODAY())
VAR closmo = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Net Sales'[LineTotal]),
    FILTER(
        ALL('Date'[Date]),
        YEAR('Date'[Date]) >= curryr - 1 && 
        YEAR('Date'[Date]) <= curryr && 
        MONTH('Date'[Date]) <= closmo
    ),
    TREATAS(VALUES('Table A'[ProductCode]), 'Net Sales'[ProductCode]),
    TREATAS(VALUES('Table B'[SubCategory]), 'Net Sales'[SubCategory])
)

 

The Third Option is for relationships exist in your model (CROSSFILTERS):

2YTDNetDollar =
VAR curryr = YEAR(TODAY())
VAR closmo = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Net Sales'[LineTotal]),
    FILTER(
        ALL('Date'[Date]),
        YEAR('Date'[Date]) >= curryr - 1 && 
        YEAR('Date'[Date]) <= curryr && 
        MONTH('Date'[Date]) <= closmo
    ),
    CROSSFILTER('Net Sales'[ProductCode], 'Table A'[ProductCode], BOTH),
    CROSSFILTER('Net Sales'[SubCategory], 'Table B'[SubCategory], BOTH)
)

 

  • I would recommend Option 2 Cause it is best for most paginated report scenarios and better performance and star schemas.

Let me Know if this works ☺️❤️

 

if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

 

Perfect! Thank you for the thorough and helpful solution. This is great. One day maybe I'll understand these things but it working is the next best thing to knowledge 😉 

Good Luck My Friend ☺️❤️

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 Fabric 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.