Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
brief001
Helper II
Helper II

Addition to a certain level, to calculate with that.

 

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.

brief001_0-1664609932909.png

 

 

 

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.

brief001_1-1664609968238.png

 

 

 

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.

brief001_2-1664609993600.png



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"

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @brief001 
The criteria for "Good" is not clear therefore, I assumed. Please refer to attached sample file.

1.png2.png

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]
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @brief001 
The criteria for "Good" is not clear therefore, I assumed. Please refer to attached sample file.

1.png2.png

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors