Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I have two fact tables. This contains the amount achieved on a daily basis and on a district level.
And in the other table is also on a daily basis and at district level only in this we see the expected target.
We do have the expected target at district level, but the target applies at cluster level.
So both the target and the amount achieved must be added up on a daily basis to the achieved cluster level.
The wish is that I get three measurements.
One that indicates with a 1 or 0 whether the achieved amount was higher or equal to the expected target.
One measurement should become the denominator of the fraction.
And the last measurement is the result of the fraction in percentage.
Examples Table 1:
let
Bron = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrLUNbDUNTJS0lFyziktLkktUghKTQHyXDKLS4oyk0sUHIEcU6VYHWLVGhoQqdiJZoqdSXAyqWoNcSp2yilNRVYdAeQY43QyNtUmRKuOJMnsSJLMjqKxaqi7jQ1ISE1UVuwEj3TqqnWmoVpDnIrxJCWqqwYlJSOSVBNvdhSNVYOSRywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Cluster = _t, District = _t, Amount = _t]),
#"Type gewijzigd" = Table.TransformColumnTypes(Bron,{{"Date", type date}, {"Cluster", type text}, {"District", type text}, {"Amount", Int64.Type}})
in
#"Type gewijzigd"
Examples Table 2:
let
Bron = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tdKxCoMwEAbgV5HMCiaxrRkb+wSd2opTm0Fw0vj+XlooUu7gz9Dx4OPncvn7XhlX1a4yRpWqm9Ylhrm4hhdNl3GJ8/iMxZmGRg0lah1oPQ3aZOAWtB0NxwyLPi5ZLQb7aQ17faPBiLfgtIX1PWUfcrQVH/mrH+kicPZbZ2Xbz5fbGulSm2G1BrH/9gOzDWhTP05/stpKmG2SeDdWi4uwvRP/j+2deGi2G/Deu5aCmqKHDQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Cluster = _t, District = _t, Target = _t]),
#"Type gewijzigd" = Table.TransformColumnTypes(Bron,{{"Date", type date}, {"Cluster", type text}, {"District", type text}, {"Target", Int64.Type}})
in
#"Type gewijzigd"
Solved! Go to Solution.
Hi @brief001
The criteria for "Good" is not clear therefore, I assumed. Please refer to attached sample file.
Total Amount = SUM ( Amount[Amount] )
Total Target = SUM ( Target[Target] )
# Good =
SUMX (
CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( 'Cluster'[Cluster] ) ),
IF (
[Total Amount] >= [Total Target],
1,
0
)
)
Denominator =
SUMX (
CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( 'Cluster'[Cluster] ) ),
1
)
% Good =
DIVIDE (
[# Good],
[Denominator]
)
Hi @brief001
The criteria for "Good" is not clear therefore, I assumed. Please refer to attached sample file.
Total Amount = SUM ( Amount[Amount] )
Total Target = SUM ( Target[Target] )
# Good =
SUMX (
CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( 'Cluster'[Cluster] ) ),
IF (
[Total Amount] >= [Total Target],
1,
0
)
)
Denominator =
SUMX (
CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( 'Cluster'[Cluster] ) ),
1
)
% Good =
DIVIDE (
[# Good],
[Denominator]
)
Hi @tamerj1 ,
Your solution is fantastic, and does exactly what I wanted. In my model I also had two dimension tables linked to both tables. This allowed me to take over your meetings right away.
I was not yet familiar with the crossjoin, so I immediately looked up more about it, it is now clear to me.
Thank you so much! My weekend is already a success, thanks to your response.
User | Count |
---|---|
47 | |
27 | |
23 | |
18 | |
15 |
User | Count |
---|---|
55 | |
34 | |
18 | |
17 | |
15 |