Forum Discussion
Filter attribute in list
- 6 years ago
Hi BK
Please consider this solution
The problem
========
You have a order header table with a status flag = open or closed.
You have a order line table with has a many:1 relationship with the order header table.
The order line table has a closed date and payment date column..
Your requirement is to have 2 slicers with payment date and order status with closed, open or both.
- If status slicer = closed than show all orders that have a closed date <= payment date slicer
- If status slicer = open than show all orders that have a closed date = blank or closed date > payment date slicer
- If status slicer = both than show all orders
The solution
=======
1) Add your tables
OrderHeader
OrderID
OrderChannel
OrderStatus
1
Phone
Open
2
Web
Closed
3
Mail Order
Open
4
Over counter
Closed
5
Phone
Open
6
Web
Closed
7
Mail Order
Open
8
Over counter
Closed
9
Web
Open
OrderLine
OrderID ClosedDat PaymentDate Qty 1 01/01/2020 01/02/2020 10 2 01/02/2020 01/01/2020 20 3 01/01/2020 30 4 01/01/2020 01/02/2020 40 4 01/01/2020 01/02/2020 50 4 01/01/2020 60 5 01/03/2020 70 5 01/03/2020 80 6 01/03/2020 01/04/2020 90 6 01/03/2020 01/04/2020 100 6 01/01/2020 01/04/2020 110 7 01/05/2020 120 8 01/05/2020 130 9 01/05/2020 01/05/2020 140 ListOfOptions
OptionID
OptionName
1
Closed not paid
2
Open not paid
3
Both
Calendar
Date
01/01/2019
etc, etc
31/12/2020
2) Add relationships
Add a 1:M relationship between OrderHeader and OrderLine.
But leave the Calendar table disconnected.
3) Add date slicer
Drag the Calendar date to a single drop down slicer (dont use a date range)
4) Add DAX measures:-
Total qty = SUM(OrderLine[Qty])
Closed not paid =
CALCULATE([Total qty],OrderHeader[OrderStatus]="Closed",
FILTER(OrderLine,OrderLine[ClosedDate]< MIN('Calendar'[Date])))
Open not paid =
CALCULATE([Total qty],OrderHeader[OrderStatus]="Open",
FILTER(OrderLine,OrderLine[ClosedDate] = BLANK() ||
OrderLine[ClosedDate] > MIN('Calendar'[Date])))
Selected qty =
SWITCH(
SELECTEDVALUE(ListOfOptions[OptionID]),
1,[Closed not paid],
2,[Open not paid],
3,[Total qty],
BLANK()
5) Add a table visual with
OrderHeader[OrderId]
Selected qty
6) Test and see if it works!
Try this OneDrive link to a PBIX example I created for you.
I will delete it after a few days.
amitchandak I'm sorry but I don't know how to do that.
speedramps Thank you very much for your time and effort! With your solution my list now does what I want it to do :-D. We use unrelated date-tables all the time but with this report I haven't thought of it at all.
Thanks!
Thank you BK1234 for the feedback. I am glad it worked ok and I enjoyed my spare time helping you during covid-19 lockdown.