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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.