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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
edwsmeadmin
Frequent Visitor

Using CALCULATETABLE with GROUP BY and IF

So, I have 1 flat file "abc". My business case is, i have to extact 2 table out of "abc".
1st table will be filtered based on "type of trasaction" and "clearance status"
2nd table will be filtered based on same columns but different values. But, this table should aggregate "Amount" if they have same "Transaction ID" and it should keep all the columns and their values that are in parent file "ABC"

Now based on transaction id, IF the aggregated amount in 2ndTable[Amount]>=1stTable[Amount] then it should say "Clear" else "Pending". 

I used CALCUATETABLE and got 1st and 2nd table, but i could get the aggregation in the 2nd table. After that i cant execute the IF function.

Table 1 and Table 2 are connected with "Transaction ID" but there is many to many relationship.

1 ACCEPTED SOLUTION
edwsmeadmin
Frequent Visitor

I got it to work.
My first Table Formula: 

S01 = CALCULATETABLE (
    C0N_R0R_104,
    C0N_R0R_104[I0T_N0E] IN { "A0H""P0C" },
    KEEPFILTERS ( C0R_R0R104[I0T_S0S] IN { "C0R""B0E" } )

I got it to work.
My first Table Formula: 

F0C = CALCULATETABLE (
    C0N_R0R_104,
    C0N_R0R_104[I0T_N0E] IN { "A0H""P0C" },
    KEEPFILTERS ( C0R_R0R104[I0T_S0S] IN { "C0R""B0E" } )

TABLE 2=  
CALCULATETABLE(C0N_R0R_104,C0N_R0R_104[R0T_T0E] = "O0C" && C0N_R0R_104[I0T_S0S] = "C0R" )

SUMMARY = 
SUMMARIZE(F0C,F0C[LOAN_ID],"A0T",SUM(F0C[I0T]))

Clear/Pending = 
CP = IF(RELATED('F0C G0P'[A0T])>='S01'[I0T],"C0R","P0G")

View solution in original post

3 REPLIES 3
edwsmeadmin
Frequent Visitor

I got it to work.
My first Table Formula: 

S01 = CALCULATETABLE (
    C0N_R0R_104,
    C0N_R0R_104[I0T_N0E] IN { "A0H""P0C" },
    KEEPFILTERS ( C0R_R0R104[I0T_S0S] IN { "C0R""B0E" } )

I got it to work.
My first Table Formula: 

F0C = CALCULATETABLE (
    C0N_R0R_104,
    C0N_R0R_104[I0T_N0E] IN { "A0H""P0C" },
    KEEPFILTERS ( C0R_R0R104[I0T_S0S] IN { "C0R""B0E" } )

TABLE 2=  
CALCULATETABLE(C0N_R0R_104,C0N_R0R_104[R0T_T0E] = "O0C" && C0N_R0R_104[I0T_S0S] = "C0R" )

SUMMARY = 
SUMMARIZE(F0C,F0C[LOAN_ID],"A0T",SUM(F0C[I0T]))

Clear/Pending = 
CP = IF(RELATED('F0C G0P'[A0T])>='S01'[I0T],"C0R","P0G")
Anonymous
Not applicable

Hi @edwsmeadmin,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

PaulDBrown
Community Champion
Community Champion

Can you please post some sample data? (Actual sample table, not an image)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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