diff --git a/python/dune/perftool/ufl/dimensionindex.py b/python/dune/perftool/ufl/dimensionindex.py
index e7c48a25581fb950095ce121514336ef14212944..e5fb3e9ffe92a02c0aab9563f3190b7f0467bf4f 100644
--- a/python/dune/perftool/ufl/dimensionindex.py
+++ b/python/dune/perftool/ufl/dimensionindex.py
@@ -22,6 +22,9 @@ class _DimensionIndexMapping(MultiFunction):
         subelement = select_subelement(o.ufl_operands[0].ufl_element(), o.ufl_operands[1])
         self.shape = len(subelement.value_shape())
 
+    def coefficient(self, o):
+        self.shape = len(o.ufl_element().value_shape())
+
     def indexed(self, o):
         self.call(o.ufl_operands[0])
         for i in range(self.shape):