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

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.

Reply
TheoM
Helper I
Helper I

How to filter table on a calculated balance sheet date?

Hello all,

 

I have an issue that should be quite easy to solve, but i haven't found the solution yet. I hope someone can help me with this.

 

My data model consists of several tables, some are amounts per month (such as turnover) and some are balances (such as amount of stock as per balance sheet date).

 

I want to add a slicer so I can select several months and I want to retrieve the opening balance amount from my stock table. My date table contains an opening balance column (first of month minus 1), so it is easy to create a measure that calculates the opening balance date for the selected period of several months. However, i cannot use this measure to filter my stock table (this table contains stock per end of each month): when I use this measure as filter in a calculate function, the result is an error: A function CALCULATE has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

Does anyone have a solution for me?

 

Best regards,

Theo

 

 

1 ACCEPTED SOLUTION

@TheoM,

Use the DAX below instead.

 Stock opening balance =  calculate(sum(Stock[Stock amount]);FILTER(Stock;Stock[Date]=Datetable[opening balance date]))



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@TheoM,

Could you please post the DAX you use? Meanwhile, please check if the following similar thread helps you.

https://community.powerbi.com/t5/Desktop/DAX-Calculate-function-throws-error-when-using-calculated/t...

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helly Lydia,

 

Thanks for the link you posted, but unfortunately I didn't succeed to solve it. I want to filter my stockbalance table, this table contains the stock amount for each month. If I select a reporting periode for the months january and february, my measure "opening balance date" calculates the opening balance date whick is december 31 of the previous year. So far so good.

 

Next thing I want to do is filter my stock table by opening balance date. I tried the following: Stock opening balance =  calculate(sum(Stock[Stock amount]);Stock[Date]=Datetable[opening balance date]). At this point I get the following error: A function CALCULATE has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

I would be very grateful if you could help me out on this.

 

Regards, Theo

@TheoM,

Use the DAX below instead.

 Stock opening balance =  calculate(sum(Stock[Stock amount]);FILTER(Stock;Stock[Date]=Datetable[opening balance date]))



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lydia,

 

Thanks, that did the job.

 

Best regards,

Theo

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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