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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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")
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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.