Forum Discussion
DAX Function assistance
- 5 years ago
Hey EmiliaB_123 ,
you would create a measure for the zeros like this one:
Zeros = CALCULATE( COUNTROWS(myTable) myTable[ColumnWithZeroValues] = 0 )And a similar for the ones and a normal COUNTROWS without the filter for all values. Then you can use all of the measures in the selected time period and you get your result.
If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution βοΈ and give it a thumbs up πBest regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
Hey EmiliaB_123 ,
I think FILTER is a more complicated approach. I would just use DATESINPERIOD.
The formula would then look like this:
Zeros =
CALCULATE(
COUNTROWS(myTable)
myTable[ColumnWithZeroValues] = 0,
DATESINPERIOD (
'DateTable'[Date],
MAX ( 'DateTable'[Date] ),
-1,
YEAR
)
)
Be aware that the time intelligence functions need a proper date table. Check here how to create a date table if you don't have one:
https://softcrylic.com/blogs/power-bi-for-beginners-how-to-create-a-date-table-in-power-bi/
HI selimovd ,
I have one last question. I tried out the formula with the time reference as well and now I donΒ΄t get any values.
My DIM_Date table looks like this:
What could be the problem?
Thanks.
- selimovd5 years agoMost Valuable Professional
Hey EmiliaB_123 ,
I would guess it's the relationship between the date table and the fact table.
Can you do a double click on the relationship in the relationship view and check if they are connected by the right column?
Best regards
Denis
- EmiliaB_1235 years agoHelper II
- selimovd5 years agoMost Valuable Professional
EmiliaB_123 also looks good for me. I could take a look into the file if it doesn't contain confidential information or if you could remove sensitive data.
Otherwise it's a little hard to say without investigating further.