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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bhorvati
Frequent Visitor

Help with Column Calculation

I need to create a calculated column "Total Units" that totals the unit sales by Order Number without reference to row context.   I need the total as a calculated column since I will create a new dimension based on the size of the total.   Unit Category = if [Total Units] < 100000 then "Small" else "Big"

 

See example below.  I need a formula so that for each row where it shows order number "1000", that the new Total Units column total is 75,000.

 

This seems like it should be easy, but I have spent all day trying to figure this out.   Sorry, I'm a newbie. 

 

example.PNG

1 ACCEPTED SOLUTION

=calculate(sum(table[units]),filter(table,table[ordernumber]=earlier(table[ordernumber]))

 

be sure to write only 1 calculated colum, not 2. Get the one above working first, then modify it to return "big" or "small". This is better than having 2 columns



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

2 REPLIES 2

=calculate(sum(table[units]),filter(table,table[ordernumber]=earlier(table[ordernumber]))

 

be sure to write only 1 calculated colum, not 2. Get the one above working first, then modify it to return "big" or "small". This is better than having 2 columns



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Worked perfect Matt.  Thanks so much.   I had not even heard of the EARLIER function until just now.  

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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