The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Please look at this dashboard just created to illustrate my problem:
First slicer represents the number of years (times) where data exists for an indicator series.
Second slicer represent the year to count from.
For Albania, as i show in the table, the series count should be 3. For Armenia should be 2.
The dashboard is using this data sample:
Country | Year | Indicator | Series |
Albania | 2015 | 1.1.1 | ind1 |
Albania | 2010 | 1.1.1 | ind1 |
Albania | 2016 | 1.1.1 | ind1 |
Albania | 2018 | 1.1.1 | ind2 |
Albania | 2011 | 1.1.1 | ind2 |
Albania | 2019 | 1.1.1 | ind2 |
Albania | 2015 | 1.1.1 | ind2 |
Albania | 2010 | 2.1.1 | ind3 |
Albania | 2016 | 2.1.1 | ind3 |
Albania | 2018 | 2.1.1 | ind4 |
Albania | 2011 | 2.1.1 | ind4 |
Albania | 2019 | 2.1.1 | ind4 |
Armenia | 2011 | 1.1.1 | ind1 |
Armenia | 2010 | 1.1.1 | ind1 |
Armenia | 2016 | 1.1.1 | ind1 |
Armenia | 2018 | 1.1.1 | ind2 |
Armenia | 2020 | 1.1.1 | ind2 |
Armenia | 2019 | 1.1.1 | ind2 |
Armenia | 2015 | 1.1.1 | ind2 |
Armenia | 2016 | 2.1.1 | ind3 |
Armenia | 2016 | 2.1.1 | ind3 |
Armenia | 2018 | 2.1.1 | ind4 |
Armenia | 2011 | 2.1.1 | ind4 |
Armenia | 2020 | 2.1.1 | ind4 |
Armenia | 2010 | 2.1.1 | ind4 |
This is my measure:
IndicatorSeriesCount =
VAR FilteredData =
FILTER(
Data,
Data[Year] >= [Year Value]
)
VAR IndicatorSeriesCounts =
SUMMARIZE(
FilteredData,
Data[Indicator],
Data[Series],
"YearCount", COUNTROWS(FilteredData)
)
VAR IndicatorSeriesWithMultipleYearsCount =
COUNTROWS(
FILTER(
IndicatorSeriesCounts,
[YearCount] > [Years Value]
)
)
RETURN IndicatorSeriesWithMultipleYearsCount
I think the problem is that i need to include a distinctcount somewhere, but i am not sure where.
Download the Pbix file here
I'd appreciate any help. Thanks!
Solved! Go to Solution.
This measure did the trick:
Filtered =
VAR FilteredData =
FILTER(
Data,
Data[Year] >= [Year Value]
)
VAR SummaryTable =
SUMMARIZE(
FilteredData,
Data[Country],
Data[Indicator],
Data[Series],
"YearCount", CALCULATE(DISTINCTCOUNTNOBLANK(Data[Year]))
)
VAR IndicatorSeriesWithMultipleYearsCount =
COUNTROWS( FILTER(SummaryTable, [YearCount] >= Years[Years Value]))
RETURN
IndicatorSeriesWithMultipleYearsCount
This measure did the trick:
Filtered =
VAR FilteredData =
FILTER(
Data,
Data[Year] >= [Year Value]
)
VAR SummaryTable =
SUMMARIZE(
FilteredData,
Data[Country],
Data[Indicator],
Data[Series],
"YearCount", CALCULATE(DISTINCTCOUNTNOBLANK(Data[Year]))
)
VAR IndicatorSeriesWithMultipleYearsCount =
COUNTROWS( FILTER(SummaryTable, [YearCount] >= Years[Years Value]))
RETURN
IndicatorSeriesWithMultipleYearsCount
Hi @horaciorek
Please try
IndicatorSeriesCount =
VAR FilteredData =
FILTER(
Data,
Data[Year] >= [Year Value]
)
VAR IndicatorSeriesCounts =
SUMMARIZE(
FilteredData,
Data[Indicator],
Data[Series],
"@YearCount", COUNTROWS(Data)
)
VAR IndicatorSeriesWithMultipleYearsCount =
COUNTROWS(
FILTER(
IndicatorSeriesCounts,
[@YearCount] >= [Years Value]
)
)
RETURN
IndicatorSeriesWithMultipleYearsCount
Thanks for your effort, but it doesn't seem to do the trick. With your measure, using the values I have in the image, it gives me 3 for both countries, when it should be 2 for Armenia...
User | Count |
---|---|
28 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
36 | |
14 | |
12 | |
7 | |
7 |