Forum Discussion
Scope of Variable
Hello,
I got the result I wanted, however using two measures. What I would like to get is the same result using just one.
Here is the result achieved.
The Total returns the right sum of whatever is filtered in 'Bins'. But here is the two measure way:
Count Bins =
VAR _min = SELECTEDVALUE( Bins[min])
VAR _max = SELECTEDVALUE( Bins[max])
VAR Res =
COUNTROWS(
FILTER(Base,
Base[Value] >= _min && Base[Value] < _max
)
)
RETURN
IF(HASONEFILTER(Bins[Bins]),Res,False())First created Count Bins measure, then this one: (which is used in the table)
Count = IF(HASONEFILTER(Bins[Bins]),[Count Bins],SUMX(Bins,[Count Bins]))But what I tried to do was:
Count Bins =
VAR _min = SELECTEDVALUE( Bins[min])
VAR _max = SELECTEDVALUE( Bins[max])
VAR Res =
COUNTROWS(
FILTER(Base,
Base[Value] >= _min && Base[Value] < _max
)
)
RETURN
IF(HASONEFILTER(Bins[Bins]),Res,SUMX(Bins,Res))Obviously getting no result in Total. I´m not seeing the obvious. Is there a way withou using virtual table?
Thanks in advance
3 Replies
- Greg_Deckler
Community Champion
Fcoatis You are doing it the way I would tend to do it. Why do you need it in a a single measure or is it something you just want to do?
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
- Fcoatis
Post Patron
Greg_Deckler just wondering if I could save so many measures. And also would like to see other perspectives. Thanks
- Greg_Deckler
Community Champion
Fcoatis Not sure how you would get there without a virual table.