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.
Hi,
I've built a Calendar table for use in a Power BI report and I want to create a measure that counts the number of months for the selected year in 2 slicers. Months & Years in the future are hidden/blank in Calendar. However, when I select Years from 2019 onwards my count has an extra value
ie my Measure (MthCount) counts as follows with no Months selected:
2017 - 12 months
2018 - 12 months
2019 - 8 months
2020 (onwards) - 1 month
Then, when I select say 2 Months my Measure counts correctly ie 2.
(see attached pics)
Does anyone know what's going on here?
Cheers
Solved! Go to Solution.
I think this is because you are force an explicit blank into that column for future periods. So 2020 has one blank for the TDYearMonth column and 2019 has 7 "real" months plus the blank which equals 8. So you could either filter out the blanks or use a different approach like creating a separate columns for filtering and counting.
MthCount = COUNTROWS( FILTER(VALUES('Calendar'[TDYearMonth]), NOT(ISBLANK('Calendar'[TDYearMonth]))))
or create a calculated column like the following:
IsPriorDate = IF( 'Calendar'[Date] <= Today(), 1,0)
Then you could add IsPriorDate = 1 as a Page or Report level filter.
I think this is because you are force an explicit blank into that column for future periods. So 2020 has one blank for the TDYearMonth column and 2019 has 7 "real" months plus the blank which equals 8. So you could either filter out the blanks or use a different approach like creating a separate columns for filtering and counting.
MthCount = COUNTROWS( FILTER(VALUES('Calendar'[TDYearMonth]), NOT(ISBLANK('Calendar'[TDYearMonth]))))
or create a calculated column like the following:
IsPriorDate = IF( 'Calendar'[Date] <= Today(), 1,0)
Then you could add IsPriorDate = 1 as a Page or Report level filter.
Brilliant! Thanks for that mate. I used your first solution ie filter inside my measure and it worked perfectly. Something I hadn't thought of in that forcing a BLANK basically created a 'value'. I'm still new to PBI so this is a good early learning experience.
Thanks again.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |