Two magnetic phase transitions at T-N1 approximate to 475 K (AF1 phase) and T-N2 approximate to 240 K (AF2) are observed in YBaCuFeO5. The magnetic unit cell of AFL is four times the chemical cell, a(m) = root 2a, c(m) = 2c, and the magnetic moments within one chemical cell are antiparallel to each other. The magnetic unit cell of the low-temperature phase AF2 is similar to that of AF1 with a(M) = a(m), but with a four times larger c(M) axis, i.e., c(M) =4c(m) = 8c and a more complicated sequence along  than in AF1. Denoting the magnetic unit cell of AF1 as A, the magnetic unit cell of AF2 can be considered as built up from the sequence AA-A-A along . in the Ca-doped compound, oxygen vacancies have a detrimental effect on the long-range correlation along . As a consequence, two magnetic phases coexist: One phase with magnetic unit cell a(1) = root 2a and c(1) = c appears at room temperature, and the Neel temperature, T-N1, for the other, predominant phase decreases as compared to the undoped compound. The transition to AF2 seems to be hindered, and AF1 is observed down to 8 K in (Y0.94Ca0.06)BaCuFeO4.95.