Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Power BI filters are this "AND"ing of fields. You can apply the setup of filters for the visual, for the Page, or for the Report.
What if you have "OR" logic you need to handle. Take the following example:
Last Login > X | Last Login < X | |
Completed = Yes | Include | Include |
Completed = No | Exclude | Include |
There are a bunch of records to include, but when two conditions occur then exclude those records.
Secondly, I want the date (X) to be variable like from a time slicer.
How is this best done in Power Bi? I’m guessing this will be a new column.
Hi @RandomJoe
for your scenario its better to use DAX logic.
for example, you can create calculated column like, then filter by its value
filterFlag =
SWITCH(TRUE(),
[Completed] = "Yes", "Include",
[Completed] = "No" && [Last Login] > [X], "Exclude",
"Include"
)
do not hesitate to give a kudo to useful posts and mark solutions as solution
Please share some sample data and expected results
Today = 2/3/2020 | Example: X = 30 days | |
Last Login | Completed | Result |
1/1/2020 | No | Exclude |
1/1/2020 | Yes | Include |
1/2/2020 | No | Exclude |
1/2/2020 | Yes | Include |
1/4/2020 | No | Include |
1/4/2020 | Yes | Include |
1/21/2020 | No | Include |
1/22/2020 | Yes | Include |
Try
Measure = if(Sumx(Sheet1,if(Sheet1[Last Login]>=maxx('Date',DATEADD('Date'[Date],-30,DAY)),1,if(Sheet1[Last Login]<maxx('Date',DATEADD('Date'[Date],-30,DAY)) && Sheet1[Completed] ="Yes",1,0)))=1,"Include","Exclude")
Link :https://www.dropbox.com/s/jl2jjl9v2g8tabu/include_exclude.pbix?dl=0
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |