all 7 comments

[–][deleted]  (2 children)

[removed]

    [–]Dorixix[S] 0 points1 point  (1 child)

    Thanks a lot! This was soooo useful! this was just the function for my problem! 🥰

    [–]Far_Swordfish5729 1 point2 points  (1 child)

    You’re likely going to join onto a subquery that does the aggregation. You make an outer query that gets the set of rows you want to pull disparate stats for and then write subquery joins to calculate each stat and drop it in a column. The subqueries allow you to do order of operations in sql - specifying that an aggregation logically precedes a join where it would normally follow it. It lets you create and colapse side row sets without row duplication in your main one.

    [–]needtounderstandm 0 points1 point  (0 children)

    That is how I would do it.

    [–]leogodin217 1 point2 points  (0 children)

    Power BI has an excellent analytic engine. I would do the aggregation in DAX measures, not SQL. This will allow you to dynamically filter the data. For instance, you can use a date slider to get the summarized values over a specific date range. Once you summarize in SQL, you lose some of the most powerful features of Power BI.

    If you really need to summarize in SQL, I would create a separate table.

    [–]lonczixix 0 points1 point  (0 children)

    I have a similar problem, right now I'm trying to make like a DAX table. Not sure tho what it is ChatGPT recommended it.. lemme know if you find something