Forum Discussion
Count dates if less than.
Hello, So I have a formula that counts the less that ones already in excel, but I can't seem to replicate in power bi, How would you go about doing this. I read about using the splicer but when I press the carrot all it says is dropdown and list? Am I missing something? Brand new to Power BI btw
10 Replies
- ntaylo06Resolver II
Slicers will automatically turn in to a slider if you drag an drop a date formatted field into it. It sounds like your data type isn't set to date. To fix this, go to your data, select the column that has the date values, and set the data type to "Date" in the modeling tab.
Is a slicer what you were looking for? Or are you wanting to do it automatically?
- CmcmahanResident Rockstar
There are multiple ways to go about this. The most important question I have is "how do you want this output to look?"
Then the follow up questions
- Do you want this count as a value in a graph? In a table visual of some sort?
- Do you want this number as a card that shows how many items are less than the currently selected date?
- How are you planning to let PowerBI know which one date is currently selected?
- Are you trying to limit a graph/visual to only show items where the value is less than the 'selected value'?
The most versatile answer I have is to give you without more detailed information is code for a DAX measure that returns a count of items where the value is less than a currently selected value (selected either through placement in a table, or a slicer that selects only one item, etc):
CountLessThan = COUNTROWS(FILTER(ALL(Table), Table[Date] <= SELECTEDVALUE(Table[Date]) ) )
Or this if you're using a slicer to select the maximum date:
CountLessThan = COUNTROWS(FILTER(ALL(Table), Table[Date] <= MAX(Table[Date]) ) )
- bwhitt13864Regular Visitor
Yes a card is the end goal for this.
- ntaylo06Resolver II
bwhitt13864 wrote:Yes a card is the end goal for this.
I think you are confused. A slicer and a card are different things.