Forum Discussion
Anonymous
3 years agoNot applicable
Conditional Formatting based on a specific rule
Hey everyone! I need help with the following issue (the data in the sample pbix): Some Part Numbers belong to different projects: And, as you can see, the physical number is...
- 3 years ago
Then maybe this is what you are looking for?
Highlight different in all other projects = IF ( HASONEVALUE ( 'Table'[Part Number] ), VAR _FirstProject = MIN ( 'Table'[ProjectName] ) RETURN IF ( CALCULATE ( COUNTROWS ( VALUES ( 'Table'[ProjectName] ) ), ALLEXCEPT ( 'Table', 'Table'[Part Number] ) ) > 1, VAR _PhysicalPartNumbersCurrentProject = CALCULATETABLE ( VALUES ( 'Table'[Part Physical Number] ), 'Table'[ProjectName] = _FirstProject, ALL ( 'Table'[Part Physical Number] ) ) VAR _PhysicalPartNumbersOtherProjects = CALCULATETABLE ( VALUES ( 'Table'[Part Physical Number] ), 'Table'[ProjectName] <> _FirstProject, ALL ( 'Table'[Part Physical Number] ) ) VAR _DifferentPartNumbers = EXCEPT ( _PhysicalPartNumbersOtherProjects, _PhysicalPartNumbersCurrentProject ) VAR _CurrentProjectOnlyPartNumbers = EXCEPT ( _PhysicalPartNumbersCurrentProject, _PhysicalPartNumbersOtherProjects ) RETURN IF ( COUNTROWS ( _DifferentPartNumbers ) + COUNTROWS ( _CurrentProjectOnlyPartNumbers ) > 0, "orange" ) ) )Highlight different physical part numbers in other projects
- 3 years ago
Your download link doesn't work anymore, but according to your data model, this should work:
Highlight different in all other projects = CALCULATE( IF ( HASONEVALUE ( 'Parts'[Part Number] ), VAR _FirstProject = MIN ( 'Parts'[ProjectName] ) RETURN IF ( CALCULATE ( COUNTROWS ( VALUES ( 'Parts'[ProjectName] ) ), ALLEXCEPT ( 'Parts', 'Parts'[Part Number] ) ) > 1, VAR _PhysicalPartNumbersCurrentProject = CALCULATETABLE ( VALUES ( 'Parts'[Part Physical Number] ), 'Parts'[ProjectName] = _FirstProject, ALL ( 'Parts'[Part Physical Number] ) ) VAR _PhysicalPartNumbersOtherProjects = CALCULATETABLE ( VALUES ( 'Parts'[Part Physical Number] ), 'Parts'[ProjectName] <> _FirstProject, ALL ( 'Parts'[Part Physical Number] ) ) VAR _DifferentPartNumbers = EXCEPT ( _PhysicalPartNumbersOtherProjects, _PhysicalPartNumbersCurrentProject ) VAR _CurrentProjectOnlyPartNumbers = EXCEPT ( _PhysicalPartNumbersCurrentProject, _PhysicalPartNumbersOtherProjects ) RETURN IF ( COUNTROWS ( _DifferentPartNumbers ) + COUNTROWS ( _CurrentProjectOnlyPartNumbers ) > 0, "orange" ) ) ), ALL ( 'slicers'[project_code] ), ALL ( 'pj_code'[project_code] ) )I'd love to see your Power BI guidelines π
Anonymous
3 years agoNot applicable
The good news is: You don't need to change the code, you just need to replace the field used in the slicer with 'Parts'[ProjectName], then it works.
This is the problem, the slicer must come from the slicers[project_code], it's like a rule (but not mine) that I cannot breakπ₯
Martin_D
Solution Sage
3 years agoYour download link doesn't work anymore, but according to your data model, this should work:
Highlight different in all other projects =
CALCULATE(
IF (
HASONEVALUE ( 'Parts'[Part Number] ),
VAR _FirstProject = MIN ( 'Parts'[ProjectName] )
RETURN
IF (
CALCULATE (
COUNTROWS ( VALUES ( 'Parts'[ProjectName] ) ),
ALLEXCEPT ( 'Parts', 'Parts'[Part Number] )
) > 1,
VAR _PhysicalPartNumbersCurrentProject =
CALCULATETABLE (
VALUES ( 'Parts'[Part Physical Number] ),
'Parts'[ProjectName] = _FirstProject,
ALL ( 'Parts'[Part Physical Number] )
)
VAR _PhysicalPartNumbersOtherProjects =
CALCULATETABLE (
VALUES ( 'Parts'[Part Physical Number] ),
'Parts'[ProjectName] <> _FirstProject,
ALL ( 'Parts'[Part Physical Number] )
)
VAR _DifferentPartNumbers = EXCEPT ( _PhysicalPartNumbersOtherProjects, _PhysicalPartNumbersCurrentProject )
VAR _CurrentProjectOnlyPartNumbers = EXCEPT ( _PhysicalPartNumbersCurrentProject, _PhysicalPartNumbersOtherProjects )
RETURN
IF (
COUNTROWS ( _DifferentPartNumbers ) + COUNTROWS ( _CurrentProjectOnlyPartNumbers ) > 0,
"orange"
)
)
),
ALL ( 'slicers'[project_code] ),
ALL ( 'pj_code'[project_code] )
)
I'd love to see your Power BI guidelines π