Forum Discussion

albypeter's avatar
albypeter
Regular Visitor
1 year ago
Solved

CALCULATETABLE with filter from multiple table

Hi , Am having a scenario where a client can purchase classes for multiple students. Once the purchase is successful student will admitted to a class Tables: Invoice ==> InvoiceID, Total amount ...
  • SamsonTruong's avatar
    1 year ago

    Hi albypeter ,

    One approach is to create a calculated table that does not rely on relationships between the tables. Here is an example of a calculated table for your use case:

    PricePaid =
    SUMMARIZECOLUMNS(
        'Class Students'[StudentID],
        "TotalPaid",
            CALCULATE(
                SUMX(
                    'Invoice Lines',
                    'Invoice Lines'[Quantity] * 'Invoice Lines'[UnitPrice]
                ),
                TREATAS ( VALUES('Class Students'[InvoiceID]), 'Invoice Lines'[InvoiceID])
            )
    )


    Please let me know if this achieves your desired result.

    If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

    Thanks,

    Samson

     

    Connect with me on LinkedIn

    Check out my Blog

    Going to the European Microsoft Fabric Community Conference? Check out my Session

  • albypeter's avatar
    albypeter
    1 year ago

    Thnak you, will try the solution and update soon

  • maruthisp's avatar
    1 year ago

    Hi albypeter ,

    As per the original post, I tried to implement the solution. Please find the pbix file.

    CALCULATETABLE with filter from multiple table.pbix

     

    Best Practices:
    1.Avoid ambiguous relationships by using DAX instead of physical relationships.
    2.Use TREATAS or LOOKUPVALUE to simulate joins.
    3.Use calculated measures to dynamically compute per-student pricing.

     

    Please let me know if there is any missing things in the pbix file.

    If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks! 

     

    Best Regards, 

    Maruthi 

    LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

    X            -  Maruthi Siva Prasad - (@MaruthiSP) / X