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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
joshua1990
Post Prodigy
Post Prodigy

Filter on dimensional Data based on Date Key

Hi community!

I have a dimensional table that I would like to filter based on a date filter.

The structure is like this:

ArticleDepartmentValue
APackaging5
BPolishing6
CShipping5
A1Assembly5

 

Now, I would like to exclude / filter out based on the following conditions:

  • If Date > 01/01/2023 then
    • Remove Packaging and Shipping
  • If Date <= 01/01/2023 then
    • Remove Polishing
  • Keep Assembly allways, regardles of Date Filter.

 

How would you do that? 

2 ACCEPTED SOLUTIONS
some_bih
Super User
Super User

Hi @joshua1990 not tested with number. Still, try measure below

CALCULATE( SUM(Tabl[Value]),
FILTER('Date', 'Date'[KeyColumn]>DATE(2023,1,1)) && FILTER(Table, Table[Depatment] NOT IN {"Packaging","Shipping" )
)
+
CALCULATE( SUM(Tabl[Value]),
FILTER('Date', 'Date'[KeyColumn]<=DATE(2023,1,1)) && FILTER(Table, Table[Depatment] NOT IN {"Polishing" )
)
+

CALCULATE( SUM(Tabl[Value]),
FILTER(Table, Table[Depatment] IN {"Assembly " )
)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

sroy_16
Resolver II
Resolver II

You can try this solution as well.
FOr this you need to have 2 DAX. One as a measure and another as a calculated column.
Below are the codes.

Measure:
Current Date Filter =
MAX('Date'[Date])

Calculated Column:

Filtered =
VAR CurrentDate = [Current Date Filter]
VAR IsPackagingOrShipping =
'DimensionalTable'[Department] IN {"Packaging", "Shipping"}
VAR IsPolishing =
'DimensionalTable'[Department] = "Polishing"
VAR IsAssembly =
'DimensionalTable'[Department] = "Assembly"

RETURN
IF(
IsAssembly,
1, -- Always include Assembly
IF(
CurrentDate > DATE(2023, 1, 1),
IF(
IsPackagingOrShipping,
0, -- Exclude Packaging and Shipping
1 -- Include other departments
),
IF(
IsPolishing,
0, -- Exclude Polishing
1 -- Include other departments
)
)
)

In your visual you can Drag the "Filtered" column to the Filters pane of your visual and set it to only include rows where "Filtered" is 1.

Try this and see if the code works.

View solution in original post

2 REPLIES 2
sroy_16
Resolver II
Resolver II

You can try this solution as well.
FOr this you need to have 2 DAX. One as a measure and another as a calculated column.
Below are the codes.

Measure:
Current Date Filter =
MAX('Date'[Date])

Calculated Column:

Filtered =
VAR CurrentDate = [Current Date Filter]
VAR IsPackagingOrShipping =
'DimensionalTable'[Department] IN {"Packaging", "Shipping"}
VAR IsPolishing =
'DimensionalTable'[Department] = "Polishing"
VAR IsAssembly =
'DimensionalTable'[Department] = "Assembly"

RETURN
IF(
IsAssembly,
1, -- Always include Assembly
IF(
CurrentDate > DATE(2023, 1, 1),
IF(
IsPackagingOrShipping,
0, -- Exclude Packaging and Shipping
1 -- Include other departments
),
IF(
IsPolishing,
0, -- Exclude Polishing
1 -- Include other departments
)
)
)

In your visual you can Drag the "Filtered" column to the Filters pane of your visual and set it to only include rows where "Filtered" is 1.

Try this and see if the code works.

some_bih
Super User
Super User

Hi @joshua1990 not tested with number. Still, try measure below

CALCULATE( SUM(Tabl[Value]),
FILTER('Date', 'Date'[KeyColumn]>DATE(2023,1,1)) && FILTER(Table, Table[Depatment] NOT IN {"Packaging","Shipping" )
)
+
CALCULATE( SUM(Tabl[Value]),
FILTER('Date', 'Date'[KeyColumn]<=DATE(2023,1,1)) && FILTER(Table, Table[Depatment] NOT IN {"Polishing" )
)
+

CALCULATE( SUM(Tabl[Value]),
FILTER(Table, Table[Depatment] IN {"Assembly " )
)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors