Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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).
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.
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.
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)
Solved! Go to Solution.
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.
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.
User | Count |
---|---|
84 | |
79 | |
71 | |
48 | |
43 |
User | Count |
---|---|
111 | |
54 | |
50 | |
40 | |
40 |