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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Scholes
Frequent Visitor

Filter measure based on dimension

Hi,

 

I have th following measure

 

 Loan = CALCULATE(SUM(Balans[Bedrag VV]),Balans[Administratie ID]=3070,Balans[Rekening ID] IN {"053037"}) 

 

which returns in 2024 (period 01/01/2024 - 31/07/2024) values split by dimension x values, it is a matrix.

Now I want to filter previous periods < 01/01/2024 on exactly the same dimension x values as those with values in 2024.

So in general in earlier years I want to fix my dimension x  and show the related values of the measure. 

When there are other dimension x values which didn't have a value in 2024 then these should be excluded in the prior year selection.

 

Thank you.

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Scholes , You can try below method

Create a table that contains the dimension x values with values in 2024.
Use this table to filter the previous periods.

DAX
// Step 1: Create a table with dimension x values that have values in 2024
DimXValuesIn2024 =
SUMMARIZE(
FILTER(
Balans,
Balans[Date] >= DATE(2024, 1, 1) && Balans[Date] <= DATE(2024, 7, 31)
),
Balans[DimensionX]
)

// Step 2: Calculate the measure for previous periods using the filtered dimension x values
LoanPreviousPeriods =
CALCULATE(
SUM(Balans[Bedrag VV]),
Balans[Administratie ID] = 3070,
Balans[Rekening ID] IN {"053037"},
Balans[Date] < DATE(2024, 1, 1),
Balans[DimensionX] IN DimXValuesIn2024
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
Scholes
Frequent Visitor

Thank you this was wat I was looking for!!!  Did you use a AI tool for this solution? 

bhanu_gautam
Super User
Super User

@Scholes , You can try below method

Create a table that contains the dimension x values with values in 2024.
Use this table to filter the previous periods.

DAX
// Step 1: Create a table with dimension x values that have values in 2024
DimXValuesIn2024 =
SUMMARIZE(
FILTER(
Balans,
Balans[Date] >= DATE(2024, 1, 1) && Balans[Date] <= DATE(2024, 7, 31)
),
Balans[DimensionX]
)

// Step 2: Calculate the measure for previous periods using the filtered dimension x values
LoanPreviousPeriods =
CALCULATE(
SUM(Balans[Bedrag VV]),
Balans[Administratie ID] = 3070,
Balans[Rekening ID] IN {"053037"},
Balans[Date] < DATE(2024, 1, 1),
Balans[DimensionX] IN DimXValuesIn2024
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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