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
tim10
Helper I
Helper I

Measure only works as a filter on visual if underlying column is included

Hello

 

I have 3 tables:

a) one is a disconnected table with a list of years : 2020, 2021, 2022.

In this one i have a measure with this code:

Selected RY = selectedvalue('Reporting Year'[ReportingYear])

 

b) one is a table with dates

In this one i have a measure with this code:

 

CY0 Delayed =
var yeartoday=year(today())

return
SWITCH(true(),
month(today())=2 && day(today())<=[Hide Show Day], yeartoday-1,
month(today())=1, yeartoday-1
,yeartoday
)

 

c) one is a table with financial data and a period column.

 

I've built a measure that has the code from this link: textfile

The purpose of the measaure is to hide/show some periods based on some date of today logic. 

If i apply this measure on a visual as a "filter on this visual" it only works if the underlying column, "Period", is included in the visual. Otherwise it will do nothing. 

 

Is there a way to remove the Period column from the table and have the filter still work? 

The reason i do not need this column in my visual is because it forces me to use a matrix (for grouping purposes) while the users want a table (to export to excel and analyze date). Because this column is in the table, when exporting to excel it separates the values on multiple rows (one for each period) and complicates analysis so i need it removed.

 

Thank you

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @tim10 ,

 

According to your description, if the created measure refers to the Period field, then deleting this field will cause the formula to fail. Could you try adding a filter condition to the formula, such as ALLSELECTED (table, table[Period])


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Thank you for your reply. I tried your suggestion in the measure below. There is no error but calculations are wrong. Am I using it right? Have a nice day

 

Total Sales Calculation Current Year =

 

var selectedyear=[Selected RY]
RETURN

 

calculate(sum('table1'[TotalSales] ),filter('table1',YEAR('table1'[Period])=selectedyear),allselected('table1'[Period]))
tim10
Helper I
Helper I

Note: if the Period column is not included in the visual filtered by the measure above, all calculations are blank. Example of a measure that will be blank if the Period column is not included in the visual:

 

Total Sales Calculation Current Year =

var selectedyear=[Selected RY]
RETURN

calculate(sum('table1'[TotalSales] ),filter('table1',YEAR('table1'[Period])=selectedyear))



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.