Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
maybe I'm already overworked and this is probably a very easy problem to solve, but I can't figure it out.
I have one table where there are fields Type and Brand and there is no Product (red). In two other tables the Product field is there.
In all three tables there is a filter that the Stock now measure must be greater than 0. Only for such items do I want to add up the output - measure Sold.
In those tables (green) where Product is in the visual, products with zero stock are omitted (Products E and J).
How can I make it so that even in a table where there is no Product column in the visual, these products are omitted so that the sum of sold is the same as in the other tables, i.e. 35 and not 51?
I have a more complex data model where the sold measure analogy is calculated for a selected time period, so I would need the aggregation by product to be directly in the measure.
Sample file attached: Data
Solved! Go to Solution.
Hi @Petanek333 ,
Your workaround is a good way, you create a virtual table to remove all products which [Stock left] = 0. If the relationship between Dimtable and Fact table is one to many, you can use this workaround.
In your sample, the relationship is one to one. I think you can try my code, it will be easier.
Measure = CALCULATE(SUM('Fact table'[Out]),FILTER('Fact table','Fact table'[Stock left]<>0))
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This might be the solution. But I would really appreciate if someone confirmed it is OK to solve it like this or if there is any another better way.
FilteredSales =
VAR virtualtable =
FILTER (
SUMMARIZE (
'Fact table',
'Dim table'[Product],
"@Stock", SUM ( 'Fact table'[Stock left] )
),
[@Stock] > 0
)
RETURN
SUMX ( virtualtable, [Sold] )
Hi @Petanek333 ,
Your workaround is a good way, you create a virtual table to remove all products which [Stock left] = 0. If the relationship between Dimtable and Fact table is one to many, you can use this workaround.
In your sample, the relationship is one to one. I think you can try my code, it will be easier.
Measure = CALCULATE(SUM('Fact table'[Out]),FILTER('Fact table','Fact table'[Stock left]<>0))
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you, it is simple and better 🙂
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
108 | |
108 | |
108 | |
90 | |
61 |
User | Count |
---|---|
171 | |
138 | |
132 | |
102 | |
86 |