The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Dear community,
I have been struggling to create a new calculated column that involves sums filtered to the values of each row.
Below is a small example of my challenge. Each row represents a contribution (D) made by a contributor (A) to a recipient (B) in a particular year (C). For each row, I want to calculate the share of that row's contributor (A) of total contributions to that recipient (B) in that year (C).
So with this example, according to manual calculations, in 2000, Anne's contributions to Hawaii in 2000 comprised 41% of total contributions to Hawaii that year. I guess this requires filtered sums but I am unsure of the right functions to use.
I would appreciate any insights or advice you might have!
A. Contributor | B. Recipient | C. Year | D. Amount | Contributor share of Year Total |
Bob | New Jersey | 2000 | $41,000 | 100% |
Anne | Hawaii | 2000 | $23,000 | 41% |
Anne | Hawaii | 2000 | $5,000 | 41% |
Sue | Hawaii | 2000 | $40,000 | 59% |
Bob | New Jersey | 2001 | $56,300 | 100% |
Bob | Hawaii | 2001 | $42,000 | 81% |
Anne | Hawaii | 2001 | $10,000 | 19% |
Solved! Go to Solution.
Hi @jttdp,
For a calculated column this should work
Contributor share of year Total = DIVIDE( CALCULATE(SUM(Table1[Amount]),ALL(Table1[Amount])) ,CALCULATE(SUM(Table1[Amount]),ALL(Table1[Contributor],Table1[Amount])) ,0)
and format as percentage.
This might work both as a Calculated Column and as a MEASURE
= DIVIDE ( CALCULATE ( SUM ( Table1[Amount] ), ALLEXCEPT ( Table1, Table1[Contributor], Table1[Recipient], Table1[Year] ) ), CALCULATE ( SUM ( Table1[Amount] ), ALLEXCEPT ( Table1, Table1[Recipient], Table1[Year] ) ) )
@MarkS, @BraneyBI and @Zubair_Muhammad, thank you all so much for your prompt responses and advice - they work well as measures!
I tried taking it a step further by referring to another table's set of values, unfortunately it will only work for me if all the references are found on the same table... but nonetheless this has been very helpful! Happy Tuesday!
Hi @jttdp,
For a calculated column this should work
Contributor share of year Total = DIVIDE( CALCULATE(SUM(Table1[Amount]),ALL(Table1[Amount])) ,CALCULATE(SUM(Table1[Amount]),ALL(Table1[Contributor],Table1[Amount])) ,0)
and format as percentage.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
82 | |
62 | |
54 | |
51 |
User | Count |
---|---|
129 | |
117 | |
82 | |
71 | |
66 |