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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Filter 3 months based on one date slicer

I have 2 tables "Order tables" and "Return Tables". My user expects to see the return orders that happened in the previous 3 months of the selected month from the slicer, meanwhile, to see the orders that happened exactly in the selected month. For example, if I selected  Mar. 2021, my users expect to see the Order list happened in Mar. 2021 and the Return order list happened between Jan. 2021 to Mar. 2021.

 

I was inspired by this post: https://community.fabric.microsoft.com/t5/Desktop/Filter-3-months-based-on-slicer-selection/td-p/309...

 

However, some of the results work well as I expect, and some of them do not. And I couldn't find the reason after I checked through my data, table relationship, and the DAX function. Please check the screenshot below to help me find out the blind spot, thanks.

 

First success case that when selected a month, shows the return list happened in previous 3 months (the table belowed).First success case that when selected a month, shows the return list happened in previous 3 months (the table belowed).

 

 

Second success case that when selected multiple months, show nothing from the return order list (table belowed).Second success case that when selected multiple months, show nothing from the return order list (table belowed).

 

Failed case that I selected one month from the month slicer at the top right, but it shows error message as the pic shows.Failed case that I selected one month from the month slicer at the top right, but it shows error message as the pic shows.

 

After checking the data that the failed case should  show, it's not because there's no data to refered.After checking the data that the failed case should show, it's not because there's no data to refered.

 

Here's the table relationship I bulit in the pbix.Here's the table relationship I bulit in the pbix.

 

Dax I use:

Return orders list P3M = 

VAR ReferenceDate = MAX('Calendar'[Date])

VAR PreviousDates =

    DATESINPERIOD(

        'Previous date'[Date],

        ReferenceDate,

        -3,

        MONTH

    )

VAR Result =

    CALCULATE(

        VALUES('V_RETURNS AND ALLOWANCES'[Return order no]),

        REMOVEFILTERS('Calendar'),

        KEEPFILTERS(PreviousDates),

        USERELATIONSHIP('Calendar'[Date], 'Previous date'[Date])

    )

RETURN

IF(HASONEVALUE('Calendar'[Month]), Result)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

So I solved this issue by the following DAX:

Return orders list P3M =

VAR ReferenceDate = MAX('Calendar'[Date])

VAR PreviousDates =

DATESINPERIOD(

'Previous date'[Date],

ReferenceDate,

-3,

MONTH

)

VAR Result =

IFERROR(

CALCULATE(

VALUES('V_RETURNS AND ALLOWANCES'[Return order no]),

REMOVEFILTERS('Calendar'),

KEEPFILTERS(PreviousDates),

USERELATIONSHIP('Calendar'[Date], 'Previous date'[Date])

),

BLANK()

)

RETURN

if(HASONEVALUE('Calendar'[Month]), Result, BLANK())

 

As you see, I only add IFERROR(..., BLANK()) to solve the problem.
I assume that there is some NULL data, multiple rows with NULL in all columns, created during the calculation which confused the software to show the result. 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

So I solved this issue by the following DAX:

Return orders list P3M =

VAR ReferenceDate = MAX('Calendar'[Date])

VAR PreviousDates =

DATESINPERIOD(

'Previous date'[Date],

ReferenceDate,

-3,

MONTH

)

VAR Result =

IFERROR(

CALCULATE(

VALUES('V_RETURNS AND ALLOWANCES'[Return order no]),

REMOVEFILTERS('Calendar'),

KEEPFILTERS(PreviousDates),

USERELATIONSHIP('Calendar'[Date], 'Previous date'[Date])

),

BLANK()

)

RETURN

if(HASONEVALUE('Calendar'[Month]), Result, BLANK())

 

As you see, I only add IFERROR(..., BLANK()) to solve the problem.
I assume that there is some NULL data, multiple rows with NULL in all columns, created during the calculation which confused the software to show the result. 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors