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
Anonymous
Not applicable

group by and difference

Hello all

 

I thank you in advance for your help with this. I have something like this and I want to do the difference of each grade column between each session for each subject and each student. I try to make a group by in the transform data but there is only the possiblity to make sum and other not relevent functions. I need the difference. What do you suggest for this. 

I need to get from table 1 to table 2 in the example.

Thanks a lot for this!

 

enath_nakash_0-1602603840841.png

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @enath_nakash,

 

Here are the steps you can follow:

 

1. According to your requirements, create the data, named Table.

v-yangliu-msft_0-1602723411509.png

2. Use calculation table.

New Table:

Table_test =
SUMMARIZE('Table','Table'[subject],'Table'[student],
"dif grad1",CALCULATE(MAX('Table'[grade 1]),'Table'[session]=1)&"-"&CALCULATE(MIN('Table'[grade 1]),'Table'[session]=2),
"dif grad2",CALCULATE(MAX('Table'[grade 2]),'Table'[session]=1)&"-"&CALCULATE(MIN('Table'[grade 2]),'Table'[session]=2))

3. Result.

v-yangliu-msft_1-1602723411514.jpeg

 

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @enath_nakash,

 

Here are a few ways to Help copying a column to another table:

1. You may try Merge Queriesin Query Editor.

2. If you have a relationship between table 1 and table 2 you can use related function, if not, try the lookupvalue function .

Information about these two fuctions below:

https://docs.microsoft.com/zh-cn/dax/lookupvalue-function-dax

https://docs.microsoft.com/zh-cn/dax/related-function-dax

 

Best Regards,

Liu Yang

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

v-yangliu-msft
Community Support
Community Support

Hi  @enath_nakash,

 

Here are the steps you can follow:

 

1. According to your requirements, create the data, named Table.

v-yangliu-msft_0-1602723411509.png

2. Use calculation table.

New Table:

Table_test =
SUMMARIZE('Table','Table'[subject],'Table'[student],
"dif grad1",CALCULATE(MAX('Table'[grade 1]),'Table'[session]=1)&"-"&CALCULATE(MIN('Table'[grade 1]),'Table'[session]=2),
"dif grad2",CALCULATE(MAX('Table'[grade 2]),'Table'[session]=1)&"-"&CALCULATE(MIN('Table'[grade 2]),'Table'[session]=2))

3. Result.

v-yangliu-msft_1-1602723411514.jpeg

 

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous , Create two new measures

grade1 diff = calculate(sum(Table[grade1]), filter(Table, table[Seesion]=1)) -calculate(sum(Table[grade1]), filter(Table, table[Seesion]=2))

grade2 diff = calculate(sum(Table[grade2]), filter(Table, table[Seesion]=1)) -calculate(sum(Table[grade2]), filter(Table, table[Seesion]=2))

Anonymous
Not applicable

Thank you so much for that!!

 

How if I want to add to this new table we just created a column from another table ?

I have a table C with a column grade 3 that I want to add to the new table you just created. How does it make sence after your summarize?

Thanks so much

Anonymous
Not applicable

Thank you so much, But how do you deal with the subject in your measure. Here the example after adding subject

subjectsessionstudentgrade 1grade 2
10001110010
100021500
100012905
100022905
2000111009
2000211001
200012704
200022905
     
subjectstudentdif grad1dif grad2  
10001100-5010-0 
1000290-905  minus 5
20001100-1009 minus 1 
2000270-904 minus 1 

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.