cancel
Showing results for 
Search instead for 
Did you mean: 
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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors