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
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")
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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
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.