Forum Discussion
vissvess
Helper V
7 years agoGCD for multiple values
Hi all, I recently came accross a requirement to get a calculated column that gets a GCD of multiple values in the related table. Unfortunately, DAX syntax for GCD is for only two values. My ...
- Anonymous7 years ago
Here you are:
- 7 years ago
Zubair_Muhammad
Community Champion
7 years agoHI vissvess Anonymous
Here is a DAX possibility
Could be very slow.
But it works with sample data
Pen_Size =
VAR possible_GCDs =
GENERATESERIES ( 2, MAXX ( RELATEDTABLE ( 'DataTable' ), [Confirmed] ) )
VAR temp =
ADDCOLUMNS (
possible_GCDs,
"Check",
VAR mycount =
COUNTROWS ( RELATEDTABLE ( 'DataTable' ) )
VAR possibleValues =
CALCULATETABLE ( VALUES ( 'DataTable'[Confirmed] ) )
RETURN
SUMX (
possibleValues,
IF ( [Confirmed] / [Value] = INT ( [Confirmed] / [Value] ), 0, 1 )
)
)
RETURN
MAXX ( FILTER ( temp, [Check] = 0 ), [Value] )
Zubair_Muhammad
Community Champion
7 years ago- Anonymous7 years agoNot applicableI'd strongly suggest not to do this in DAX unless your model is small. If it's big, this will be not only slow but the compression rate will suffer.
Best
Darek- vissvess7 years ago
Helper V
Yes, Ofcourse. My data has unique ID of around 1k values.
The transactions may go upto 16k+ and recurring.
I'll take the point.
Thanks