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

Group by repeated values, filter by a flag value, and sum the result

I have the following table with repeated records, except for the sale column. I need, according to this example, to group by the date, state, and contract columns, and of the records that I have left, to filter by the value of the state = 1 column and hence the one with the maximum value of the date field, the sum from the Contract Value column:

 

Date       State              Contract            contract Value         Sales Type
202001       1                123456              34.000                     shoes
202001       1                123456              34.000                     socks

202001       0                123456              10.000                     socks

202001       1                234567              44.000                     shoes
202001       1                234567              44.000                     socks

202001       0                234567              10.000                     socks

202001       1                345678              55.000                     shoes
202001       1                345678              55.000                     socks

202001       0                345678              10.000                     socks

202002       0                123456              10.000                     shoes

202002       0                234567              11.000                     socks

202002       0                345678              12.000                     shoes

 

As a result, it will be the following with 133.000 as a contract value. As there is no date with value 202002 with state = 1, we will have to take the sum of the dates that have 202001 and that the state is = 1:

Date         State              Contract            Contract Value                  
202001       1                123456              34.000                    
202001       1                234567              44.000                   
202001       1                345678              55.000       

 

Thank you very much in advance,

Mayte                             

2 REPLIES 2
az38
Community Champion
Community Champion

Hi @Anonymous 

try a new calculated table

Table 2 = summarize(filter('Table';'Table'[State]=1);'Table'[Date];'Table'[State];'Table'[Contract];"Contract Value";MAX('Table'[contract Value]))

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Hi @Anonymous38,

 

Thanks for your answer, but it´s not working.

 

In this case, I need to:

First: Filter for state = 1

Second: Get the maximum value of date. In this case, it is 202001 (although it´s not a date value, it´s a number value), because 202002 has 0 value in field state.

Third: Group by Date value and contract Field and summarize Contract Value field.

 

Thanks again,

Mayte

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.