Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, sorry trying to make this work and decompressed my real-life problem into this simple case:
Essentially, I want to add a measure column to the `stores` table.
This `measure` column would find all the parents the child has and combine (sum or average) all its `some_value`'s.
I was trying to do it in a way like this
Measure = CALCULATE(SUM(stores[some_value]), FILTER(ALL(stores), 'stores'[store_child_and_parent] = VALUES(store_relationship[store_parent])))
but I feel lost.
Solved! Go to Solution.
Thanks, @Zubair_Muhammad!
Your solution kickstarted my brain and eventually I managed to figure out what I wanted!
measure = CALCULATE( SUM( 'stores'[some_value] ), FILTER( ALL('stores'), 'stores'[store_child_and_parent] in VALUES('store_relationship'[store_parent]) ) )
But then, because some_value (albeit not in this example but in my real world one) is actually a measure I was looking to get an average grouped by the child store.... was about to give up and ask here but eventually I did it!!!
measure = CALCULATE( AVERAGEX( 'stores', 'stores'[some_value] ), FILTER( ALL('stores'), 'stores'[store_child_and_parent] in VALUES('store_relationship'[store_parent]) ) )
I'm the happiest DAX newbie in the world right now!
Still trying to figure out this whole DAX thing, it seems very powerful but not as obvious.
So, in the data from your example, 5 would get a value of 666 (if summing) and 4 would be 111, correct?
Ah, sorry didn't mention it in the post. You are correct! 666 and 111!
@Anonymous
Please try this MEASURE
Measure = VAR parents = VALUES ( store_relationship[store_parent] ) VAR result = CALCULATE ( SUM ( Stores[some_value] ), FILTER ( ALL ( Stores ), Stores[store_child_and_parent] IN parents ) ) RETURN IF ( ISBLANK ( result ), 0, result )
@Anonymous
Please see attached file with your sample data
Thanks, @Zubair_Muhammad!
Your solution kickstarted my brain and eventually I managed to figure out what I wanted!
measure = CALCULATE( SUM( 'stores'[some_value] ), FILTER( ALL('stores'), 'stores'[store_child_and_parent] in VALUES('store_relationship'[store_parent]) ) )
But then, because some_value (albeit not in this example but in my real world one) is actually a measure I was looking to get an average grouped by the child store.... was about to give up and ask here but eventually I did it!!!
measure = CALCULATE( AVERAGEX( 'stores', 'stores'[some_value] ), FILTER( ALL('stores'), 'stores'[store_child_and_parent] in VALUES('store_relationship'[store_parent]) ) )
I'm the happiest DAX newbie in the world right now!
Still trying to figure out this whole DAX thing, it seems very powerful but not as obvious.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |