Forum Discussion
Problem calculating flowfield in DAX
- 11 months ago
Thankyou, johnt75, and grazitti_sapna, for your responses.
Hi data_mp_97,
We appreciate your inquiry through the Microsoft Fabric Community Forum.Based on my understanding, the discrepancy arises because the Business Central FlowField is evaluated at the header level, that is, it computes the minimum of the related sales lines. In your DAX, the measure was being evaluated at the line level, which caused a context mismatch. In addition, the FlowField excludes empty Type values and may include a Location filter, which were not fully replicated in your measure.Please follow the suggested approach below which may help to resolve the issue:1. Compute the FlowField logic at the header level and then apply it within your calculation, as shown:VentasDistriNoAlbaranadas_Final22(CB) =CALCULATE(DISTINCTCOUNT('salesheader36'[No]),'salesheader36'[PostingDate] >= DATE(2025, 8, 1),'salesheader36'[PostingDate] <= DATE(2025, 10, 2),'salesheader36'[$Company] = "DIST",FILTER (VALUES('salesheader36'[No]),VAR MinComp =CALCULATE(MINX(FILTER ('salesline37',TRIM(COALESCE('salesline37'[Type], "")) <> ""&& 'salesline37'[LocationCode] = SELECTEDVALUE(LocationTable[LocationCode])),IF('salesline37'[CompletelyShipped],1,0)))RETURN COALESCE(MinComp, 0) = 0))Using VALUES('salesheader36'[No]) ensures that the calculation is performed per header, analogous to FlowFields in Business Central. The inner MINX replicates the FlowField’s minimum across related sales lines. The TRIM(COALESCE(...)) <> "" expression corresponds to Business Central’s Type <> " " condition.For further details, please refer to the link below:
FlowFields overview - Business Central | Microsoft LearnWe hope this information helps to resolve the issue. If you have any further queries, please feel free to contact the Microsoft Fabric Community.Thank you.
No, but I was creating a DAX measure (Completely Shipped), not a calculated column.Then I use that DAX measure here:
VentasDistriNoAlbaranadas_Final22(CB)=
CALCULATE(DISTINCTCOUNT('salesheader36'[No]),
'salesheader36'[PostingDate] >= DATE(2025, 8, 1),
'salesheader36'[PostingDate] <= DATE(2025, 10, 2),
'salesheader36'[$Company] = "DIST",
FILTER('salesline37',[Completely Shipped] = 0))
Maybe the error can be seen here..
I think the issue is that when you are calling the [Completely Shipped] measure from within the FILTER clause 'salesheader36'[DocumentType] and 'salesheader36'[No] do not have single values so SELECTEDVALUE will return a blank.
Without knowing the relationships between tables it is difficult to suggest a solution, but I think the general approach would be to build a table variable containing document type and number and whether it is completely shipped or not, then get a distinct count from that table.