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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
silvapaulo22
New Member

Dax Formule

Hello, I have a difficulty, I have a table that works as a matrix. I have the sellers in a column and the week number on the top line. Each week can have a different commission. I need to create a formula that returns the commission corresponding to each week to another table in order to calculate the commission amount for that week. Can you help me? Thanks, best regards.

IMG-20230402-WA0003.jpg

IMG-20230402-WA0002.jpg

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @silvapaulo22 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table and then the result is as follows.

Table 2 = DISTINCT(SELECTCOLUMNS('Table',"week1",SUM('Table'[1]),"week2",SUM('Table'[2]),"week3",SUM('Table'[3]),"week4",SUM('Table'[4]),"week5",SUM('Table'[5]),"week6",SUM('Table'[6]),"week7",SUM('Table'[7]),"week8",SUM('Table'[8])))

vtangjiemsft_0-1680576996745.png

(3)Or you can click "transform data" to enter the Power Query editor and pivot the columns to change the source data, and then we can create a table.

Picture1.png

Table 3 = DISTINCT( SELECTCOLUMNS('Table (2)',"Week",'Table (2)'[Week],"Commission",CALCULATE(SUM('Table (2)'[Commission]),FILTER('Table (2)','Table (2)'[Week]=EARLIER('Table (2)'[Week])))))

vtangjiemsft_1-1680577246819.png

 

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @silvapaulo22 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table and then the result is as follows.

Table 2 = DISTINCT(SELECTCOLUMNS('Table',"week1",SUM('Table'[1]),"week2",SUM('Table'[2]),"week3",SUM('Table'[3]),"week4",SUM('Table'[4]),"week5",SUM('Table'[5]),"week6",SUM('Table'[6]),"week7",SUM('Table'[7]),"week8",SUM('Table'[8])))

vtangjiemsft_0-1680576996745.png

(3)Or you can click "transform data" to enter the Power Query editor and pivot the columns to change the source data, and then we can create a table.

Picture1.png

Table 3 = DISTINCT( SELECTCOLUMNS('Table (2)',"Week",'Table (2)'[Week],"Commission",CALCULATE(SUM('Table (2)'[Commission]),FILTER('Table (2)','Table (2)'[Week]=EARLIER('Table (2)'[Week])))))

vtangjiemsft_1-1680577246819.png

 

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

andhiii079845
Solution Sage
Solution Sage

I think you have to modify your source table with unpivot:

https://support.microsoft.com/en-us/office/unpivot-columns-power-query-0f7bad4b-9ea1-49c1-9d95-f5882...

 

If you need further help, pleace post some sample data from the source table





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.