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.
Hello,
I would like help using a related table to help me find a cumulative sum.
I have a fact table fGALT which has various columns including fGALT[Flange Qty] which is a whole number and fGALT[Size] which is a pipe size in text format such as 1", 1-1/2", 2" ...
I have a related table dPipeSize which is primarily used as slicer. dPipeSize has a unique list of pipe sizes (e.g. 1", 1-1/2", 2" ...) and a corresponding size code column as an integer 1, 2, 3, 4, ect..... dPipeSize table is related to the fact table using a 1 to many relationship size (e.g. 1", 1-1/2", 2" ...). The size code allows me to sort the inch based sizes nicely.
I would like to write a DAX measure that allows me to sum up all the cumulative number of flanges <= a given size on a table. If I were to flatten the fact table it is easy, but I can't seem to do it with the related table. If I flatten the fact table ( look up the size code for each pipe size I can write a measures as follows.
Flanges Tested := SUM ( fGALT[Flange Quantity] )
Then for the cumulative quantity on the flatted table I would write:
cumulative Flange Tested := CALCULATE ( [Flanges Tested], FILTER ( ALLSELECTED ( fGALT ), fGALT[Size Code] <= MAX ( fGALT[Size Code] ) ) )
If I do not flatten the table, and instead wanted to look up the size by size code on the related table, what is the proper syntax? Here is what I tried and failed with.
cumulative Flange Tested := CALCULATE ( [Flanges Tested], FILTER ( ALLSELECTED ( fGALT ), RELATED ( fGALT[Size Code] ) <= MAX ( RELATED ( fGALT[Size Code] ) ) ) )
I got an error message on that measure. Any ideas on how I can correct that?
Solved! Go to Solution.
You may refer to the DAX below.
cumulative Flange Tested = VAR s = MAX ( dPipeSize[Size Code] ) RETURN CALCULATE ( [Flanges Tested], FILTER ( ALLSELECTED ( fGALT ), RELATED ( dPipeSize[Size Code] ) <= s ) )
You may refer to the DAX below.
cumulative Flange Tested = VAR s = MAX ( dPipeSize[Size Code] ) RETURN CALCULATE ( [Flanges Tested], FILTER ( ALLSELECTED ( fGALT ), RELATED ( dPipeSize[Size Code] ) <= s ) )
Looks like I didn't need the related function at all. My solution was filtering on the related dimension table instead.
cumulative Flange Tested := CALCULATE ( [Flanges Tested], FILTER ( ALL ( PipeSize ), RELATED ( PipeSize[Size Code] ) <= MAX ( RELATED ( PipeSize[Size Code] ) ) ) )
Thank you for the help.
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 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |