I want to customize my installer to show custom dialog when previous version is already installed: after Welcome dialog user should see a custom dialog OldVersionDlg>
The problem was caused by the second line in WixUI_Wizard.wxs. For some reason WiX always uses it. So, to implement checking of previous version we need to exclude PREVIOUSVERSIONSINSTALLED from the second condition:
PREVIOUSVERSIONSINSTALLEDNOT Installed AND NOT PREVIOUSVERSIONSINSTALLED