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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Aucesar
Helper III
Helper III

DAX Calculation Help

Hi Community another day, another challenge 🙂

 

Need to acomplish this calculation...thanks for any help in advance!

 

DateMainWorkerAssistantTotalItensDefectoiTens%DefectoDesired Result = Sum all % results when the worker is Main or Assistant%Total
day1employee1employee210055%Employee110%
day1employee3employee41001010%Employee210%
day1employee5employee61001515%Employee330%
day1employee7employee810000%Employee435%
day2employee2employee310055%Employee535%
day2employee4employee51001010%Employee635%
day2employee6employee71001515%Employee725%
day2employee8employee110000%Employee80%
day3employee6employee110055%  
day3employee7employee51001010%  
day3employee3employee41001515%  
day3employee2employee810000%  
1 ACCEPTED SOLUTION
vicky_
Super User
Super User

vicky__0-1691015219363.png

Calculation = 
var helperTable = UNION(
    SELECTCOLUMNS(ALL('Table'), "workers", 'Table'[MainWorker], "defecto", 'Table'[%Defecto]), 
    SELECTCOLUMNS(ALL('Table'), "workers", 'Table'[Assistant], "defecto", 'Table'[%Defecto])
)
return SUMX(FILTER(helperTable, [workers] = SELECTEDVALUE('Table'[MainWorker])), [defecto])

Hope this helps.

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, select all columns other than Main Worked and Assistant, right click and select Unpivot Other columns.  Rename the Atribute column as Employees.  Drag the Employees column to the visual and write this measure

Measure = sum(Data[%Defecto])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
vicky_
Super User
Super User

vicky__0-1691015219363.png

Calculation = 
var helperTable = UNION(
    SELECTCOLUMNS(ALL('Table'), "workers", 'Table'[MainWorker], "defecto", 'Table'[%Defecto]), 
    SELECTCOLUMNS(ALL('Table'), "workers", 'Table'[Assistant], "defecto", 'Table'[%Defecto])
)
return SUMX(FILTER(helperTable, [workers] = SELECTEDVALUE('Table'[MainWorker])), [defecto])

Hope this helps.

Hi @vicky_  awesome! Thank you....

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors