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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
eversoncarvalho
Frequent Visitor

SUM VALUES FROM 2 DISTINCT COLUMNS

Hello, people.

 

eversoncarvalho_0-1652376962485.png

 

 

As you guys can see on the table above, I´have more than one "seller" per "order_num" and it’s ok. But I need to SUM the "sku_qtd" without repeating the items from the order. Right now, SUM is returning 6 instead of 3.

Pls help me, I have been looking for an answer for hours.

1 ACCEPTED SOLUTION

@eversoncarvalho 
Measure = SUMX(SUMMARIZE('Table', 'Table'[order_num],'Table'[squ_name]), ,CALCULATE(AVERAGE('Table'[squ_qtd])))


2022-05-09 21_46_30-Auto sign in click on _Sign-in_ if button appears ... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @eversoncarvalho 
You can try

sku_qtd =
DIVIDE (
    SUM ( TableName[ColumnName(SKU Qty)] ),
    DIVIDE ( COUNTROWS ( TableName ), ( TableName[ColumnName(SKU Name)] ) )
)
SpartaBI
Community Champion
Community Champion

@eversoncarvalho 
If you just want to count the number of sellers do:
Measure = DISTINCTCOUNT('Table'[seller])
If you just want to count the number of sku's do:
Measure = DISTINCTCOUNT('Table'[squ_name])
If you want to count the number of sellers that will add app on different orders create this measure:
Measure = SUMX(VALUS('Table'[order_num]),DISTINCTCOUNT('Table'[seller]))
If you want to count the number of squ's that will add app on different orders create this measure:
Measure = SUMX(VALUS('Table'[order_num]),DISTINCTCOUNT('Table'[squ_name]))

'Table' is the name of your table so replace that in the code.


2022-05-09 21_46_30-Auto sign in click on _Sign-in_ if button appears ... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

I want to know the amount sold by sku_qtd without repeating the sku_name and order_num

@eversoncarvalho 
Measure = SUMX(SUMMARIZE('Table', 'Table'[order_num],'Table'[squ_name]), ,CALCULATE(AVERAGE('Table'[squ_qtd])))


2022-05-09 21_46_30-Auto sign in click on _Sign-in_ if button appears ... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

eversoncarvalho_0-1652382297532.png

Here, I think I have a better explanation of what I need. How can I get the number of qtd sold by crm_medic without repeating the product of the order?

@eversoncarvalho just replace the squ name in that column in my previous measure, but it seems that the other measure will also work the same. Have you tried it? Put it instead of the qty column in the visual

@eversoncarvalho pat attension that I added a calculate now to the previous measure. Please use the new version. The old one worked for you becasue all the values were 1 but it will not give the right number in the total in other cases. So use the new version with calculate.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors