Forum Discussion
Power BI Modeling Question โ Dynamic Common Sample + Buckets + Weighted KPIs
- 3 months ago
I think you need to use a calculation group so that you can work out the list of valid companies and then use that as a filter on your chosen measure.
Create a calculation item like
Company is in common sample = VAR _Years = TREATAS ( VALUES ( 'Sample Years'[Year] ), 'Date'[Year] ) VAR _NumYears = COUNTROWS ( _Years ) VAR _CompaniesYearsAndNumbers = CALCULATETABLE ( SUMMARIZECOLUMNS ( Company[Company ID], 'Date'[Year], "@Net sales", [Net sales], "@ebitda", [EBITDA], "@total assets", [Total assets] ), REMOVEFILTERS (), _Years ) VAR _CompaniesYears = FILTER ( _CompaniesYearsAndNumbers, [@Net sales] <> 0 && [@ebitda] <> 0 && [@total assets] <> 0 ) VAR _CompaniesAndNumYears = GROUPBY ( _CompaniesYears, Company[Company ID], "@num years", SUMX ( CURRENTGROUP (), 1 ) ) VAR _ValidCompanies = SELECTCOLUMNS ( FILTER ( _CompaniesAndNumYears, [@num years] = _NumYears ), Company[Company ID] ) VAR Result = CALCULATE ( SELECTEDMEASURE (), KEEPFILTERS ( _ValidCompanies ) ) RETURN Resultand then apply that as a filter to the visuals you want to be affected by your common sample filters.
The algorithm is relatively straitforward. First you need to calculate the qualifying measures for each company for each year selected. You can then filter out those rows where the qualifying measures are not all non-zero, and count the number of remaining years for each company.
You only want the companies where the number of valid years matches the number of years selected by the user, and you can use that list of valid companies as an additional filter on top of any other existing filters to calculate the underlying measure.
- 3 months ago
Hi,
I'm attaching a test.pbix, pls check if this is what you are looking for. https://drive.google.com/file/d/141G2onZUkz8eInk4OPWa_sbB0Uc_96Iz/view?usp=drivesdk
Hello atziovara,
Hope everythingโs going great with you. Just checking, the issue been resolved or are you still running into problems? Sharing an update can really help others facing the same thing.
Thank you.