Forum Discussion
Sum Value based on distinct record from other column
If i understand you correctly, you want me to have a new table?
The data i have shared is just part of the so many records (15000 rows) and for that cannot create a new table.
Need to use existing table and show the visuals based on my requirements
CJ_96601 Ok, if you don't want to create an another table (summarized). Then follow the below steps as an alternate method.
Please add a new column to your source table as below
MaxFlag = VAR _MaxVal = CALCULATE(MAX(Test219MaxSum[Amount]),FILTER(Test219MaxSum,Test219MaxSum[BadgeNo]=EARLIER(Test219MaxSum[BadgeNo]) && Test219MaxSum[Year] = EARLIER(Test219MaxSum[Year]))) RETURN IF(Test219MaxSum[Amount] = _MaxVal,"Y","N")
Then have a visual level filter as below.
Hope this helps !!
- CJ_966017 years ago
Helper V
Thanks.
Shall i add column in Power bi query or in excel file?
- PattemManohar7 years ago
Community Champion
- CJ_966017 years ago
Helper V
Hi,
I used this and it works..
SUMX ( DISTINCT( Sheet1[BADGENO] ),CALCULATE ( MAXX (Sheet1,Sheet1[Amount] ) ) )just need help on how to create systax to link it to the year.thanks - PattemManohar7 years ago
Community Champion
CJ_96601 Please update your Measure logic as below and use your Year field as a filter.
Test219 = VAR _Total = SUMX(SUMMARIZE(Test219MaxSum,Test219MaxSum[BadgeNo],Test219MaxSum[Year],"Amount",MAX(Test219MaxSum[Amount])),[Amount]) RETURN IF(HASONEFILTER(Test219MaxSum[Year]),SUMX(DISTINCT(Test219MaxSum[BadgeNo]),CALCULATE(MAXX(Test219MaxSum,Test219MaxSum[Amount]))),_Total)
- CJ_966017 years ago
Helper V
Hi, thank you for your response.
The date (year) i am currently using is in another table.
Do i need to make a relationship between the two tables.
As of now, there is only one active relationship in power bi
- CJ_966017 years ago
Helper V
Furthermore, if i make a relationship (Year), if i click year 2020, the result is zero , null, as there is no record in 2020. What i would like to have is to have 2019 sum even if i click 2020.
Regards,
- PattemManohar7 years ago
Community Champion
CJ_96601 Yes it should have a relationship based on the Year field from which table you want to get it as a filter.
- CJ_966017 years ago
Helper V
is it possible not having a relationships but create the filter by year (in the measure)?