Forum Discussion
Anonymous
5 years agoNot applicable
Having a dynamic flag depending on selected date
Hi, I'm new at Power BI and got asked to solve a task my co-worker has. The data model is for a restaurant chain that wants to be able to compare different locations, years and months with a ...
- Anonymous5 years ago
// Create a filtering measure that // will return 1 for the restaurants // you want to see and 0 otherwise. // Then, when you display your restaurants // in a table or matrix, just put this // measure in the Filter Pane of the visual // and set the "is" condition to 1. [Show Restaurant?] = IF( ISINSCOPE( Venue[Restaurant] ), var OpenDate = SELECTEDVALUE( Venue[OpeningDate] ) var ComparisonYear = SELECTEDVALUE( CompareYear[CompareYear] ) var BaseMonthNumber = MONTH( MIN( 'Date Table'[Date] ) ) var CutoffDate = DATE( ComparisonYear, BaseMonthNumber, 1 ) var ShouldShow = OpenDate < CutoffDate return INT( ShouldShow ) )
sayaliredij
5 years agoSolution Sage
Hi,
You can use the following formula to count restaurants opened
Restaurant Count =
var selectedyear = SELECTEDVALUE('Year'[Year],2021)
RETURN
CALCULATE(COUNTROWS('Table') , 'Table'[Opening Date] < DATE(selectedyear,12,31))
Best,
Sayali
If this post helps, then please consider Accept it as the solution to help others find it more quickly.