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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Check for values in group

Hi,

 

I have a datatable similar to the following:

CategoryIDdategoodbadundecided
Cat111AAsome_date100
Cat111AAsome_date100
Cat122BBsome_date100
Cat122BBsome_date100
Cat122BBsome_date010
Cat233CCsome_date100
Cat233CCsome_date010
Cat233CCsome_date001
Cat244DDsome_date100
Cat244DDsome_datenullnullnull

The rules are:

  • There is always just one value in columns "good", "bad" and "undecided" for each row.
  • There may be rows with null values in all of those columns, assume then it's "good".

What I need are measures:

  • Measure 1: If all values for certain ID are "good" return 1, else return 0.
  • Measure 2: If there is any "bad" value check, if there is any "undecided" value and choose last one by date.
  • Measure 3: If there is any "undecided value check, if there is any "bad" value and choose last one by date.
    So if there is one bad and one undecided the result value for this ID should be the last one.

So the result visual matrix should look like this:

CategoryIDMeasure 1 [good]Measure 2 [bad]Measure 3 [undecided]
Cat1 110
 11AA100
 22BB010
Cat2 101
 33CC001
 44DD100


I can't figure it out, I tried with SUMMARIZECOLUMNS and GROUPBY functions but in each approach the problem was I couldnt summarize the result table.

Thank you in advance!

1 ACCEPTED SOLUTION
rajulshah
Resident Rockstar
Resident Rockstar

Hello @Anonymous,

Please create following measures:

Good Rating = 
VAR SelectedID = SELECTEDVALUE(Rating[ID])
VAR TotalValues = CALCULATE(COUNT(Rating[ID]),FILTER(ALL(Rating),Rating[ID]=SELECTEDVALUE(Rating[ID])))
VAR GoodRatingCount = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[good]=1 || ISBLANK(Rating[good])))
VAR GoodRating = IF(TotalValues=GoodRatingCount,1,0)
VAR CategoryRatingTable = FILTER(SUMMARIZE(Rating,Rating[Category],Rating[ID],"GoodRating",CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[good]=1 || ISBLANK(Rating[good]))),"TotalValues",CALCULATE(COUNT(Rating[ID]),ALLEXCEPT(Rating,Rating[ID]))),[GoodRating]=[TotalValues])
RETURN IF(ISBLANK(SelectedID),COUNTX(CategoryRatingTable,Rating[ID]),GoodRating)
Bad Rating = 
VAR TotalValues = CALCULATE(COUNT(Rating[ID]),FILTER(ALL(Rating),Rating[ID]=SELECTEDVALUE(Rating[ID])))
VAR BadRating = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[bad]=1 || ISBLANK(Rating[bad])))
VAR Undecided = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[undecided]=1 || ISBLANK(Rating[undecided])))
RETURN IF(BadRating>=1 && Undecided=0,1,0)
Undecided Rating = 
VAR TotalValues = CALCULATE(COUNT(Rating[ID]),FILTER(ALL(Rating),Rating[ID]=SELECTEDVALUE(Rating[ID])))
VAR Undecided = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[undecided]=1 || ISBLANK(Rating[undecided])))
RETURN IF([Good Rating]=0 && [Bad Rating]=0 && Undecided>0,1,0)

 

The result is as follows:
Rating.pngHope this helps.

View solution in original post

2 REPLIES 2
rajulshah
Resident Rockstar
Resident Rockstar

Hello @Anonymous,

Please create following measures:

Good Rating = 
VAR SelectedID = SELECTEDVALUE(Rating[ID])
VAR TotalValues = CALCULATE(COUNT(Rating[ID]),FILTER(ALL(Rating),Rating[ID]=SELECTEDVALUE(Rating[ID])))
VAR GoodRatingCount = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[good]=1 || ISBLANK(Rating[good])))
VAR GoodRating = IF(TotalValues=GoodRatingCount,1,0)
VAR CategoryRatingTable = FILTER(SUMMARIZE(Rating,Rating[Category],Rating[ID],"GoodRating",CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[good]=1 || ISBLANK(Rating[good]))),"TotalValues",CALCULATE(COUNT(Rating[ID]),ALLEXCEPT(Rating,Rating[ID]))),[GoodRating]=[TotalValues])
RETURN IF(ISBLANK(SelectedID),COUNTX(CategoryRatingTable,Rating[ID]),GoodRating)
Bad Rating = 
VAR TotalValues = CALCULATE(COUNT(Rating[ID]),FILTER(ALL(Rating),Rating[ID]=SELECTEDVALUE(Rating[ID])))
VAR BadRating = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[bad]=1 || ISBLANK(Rating[bad])))
VAR Undecided = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[undecided]=1 || ISBLANK(Rating[undecided])))
RETURN IF(BadRating>=1 && Undecided=0,1,0)
Undecided Rating = 
VAR TotalValues = CALCULATE(COUNT(Rating[ID]),FILTER(ALL(Rating),Rating[ID]=SELECTEDVALUE(Rating[ID])))
VAR Undecided = CALCULATE(COUNT(Rating[ID]),FILTER(Rating,Rating[undecided]=1 || ISBLANK(Rating[undecided])))
RETURN IF([Good Rating]=0 && [Bad Rating]=0 && Undecided>0,1,0)

 

The result is as follows:
Rating.pngHope this helps.

Anonymous
Not applicable

Thank you, @rajulshah!

 

It took me some time to adjust your solution to my real data (I had to add lot's of additional filtering there) but the first measure works as I need it to work and thus I'm accepting your idea as the solution to my problem. I'll work with other two measures now but these probably won't be as problematic as the first one (less customization).

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors