Forum Discussion
Grouping values from measures
- 8 years ago
You should be able to do it like this:
Table = SUMMARIZE('TABLE','TABLE'[Column],"MyMeasure",[Measure])
Hi Greg_Deckler
Thanks for the reply
I have posted my query here
https://community.powerbi.com/t5/Desktop/Dynamic-Grouping-on-Sum/m-p/454924#M210785
I will try your measure and will update here.
OK, based on the data in the other post, I created a Category table with:
Category
| 0-50 percent |
| 51-75 percent |
| 75-100 percent |
And a measure like this:
Measure =
VAR __Date = MAX('Table'[date])
VAR __Category = MAX('Categories'[Category])
VAR __Low =
SWITCH(
__Category,
"0-50 percent",0,
"51-75 percent",.51,
"75-100 percent",.75
)
VAR __High =
SWITCH(
__Category,
"0-50 percent",.5,
"51-75 percent",.74,
"75-100 percent",1
)
VAR __tmpTable = SUMMARIZE('Table','Table'[userid],"__Percent",MAX('Table'[profilepercent]))
RETURN COUNTROWS(FILTER(__tmpTable,[__Percent]>=__Low && [__Percent]<=__High))PBIX is attached.
- kohlivinayak8 years agoResolver I
Hi Greg_Deckler
You rock man!!!It worked after small tweak. And you have given me a whole new dimension to figure new stuff i can do with this.
The actual query which worked for me
User Count Profile Percentage =
VAR __Category = MAX('Category'[Category])
VAR __Low =
SWITCH(
__Category,
"0-50 percent",0,
"51-75 percent",51,
"75-100 percent",75
)
VAR __High =
SWITCH(
__Category,
"0-50 percent",50,
"51-75 percent",74,
"75-100 percent",100
)
//VAR __tmpTable = SUMMARIZE('Table','Table'[userid],"__Percent",SUM('Table'[profilepercent]))
//RETURN COUNTROWS(FILTER(__tmpTable,[__Percent]>=__Low && [__Percent]<=__High))
var _Temp_tbl = SUMMARIZE('Periodic %age completion update','Periodic %age completion update'[UserId],"_sumPer", CALCULATE(SUM('Periodic %age completion update'[ProfilePercentage]),FILTER('Periodic %age completion update','Periodic %age completion update'[UpdatedDate]<='Date Dim'[Date selected] && 'Periodic %age completion update'[UpdatedDate]>= [Least Date])))
return
COUNTROWS(FILTER(_Temp_tbl,[_sumPer] >= __Low && [_sumPer] <= __High))Thanks !!!!
- Anto697 years agoRegular Visitor
I have a similar issue...
A table with 2 columns: ID, Date
I calculated the nr of days between a date that is filtered by the user and the date of every ID included in my Table.
The measure returns a correct value:
NrDays= if(HASONEVALUE(Calendar[Date]); DATEDIFF(MAX('Table'[Date]);MAX('Calendar'[Date]);DAY);0)
I created a table with this grouping:
0-100
100-500
500-1000
I want to count how many id I have in the first group, the second and the third based by my measure NrDays ( for example if I have 3 ID with Nr Days=21,30 and 80 I want to count 3 in the first range 0-100)
How can I achieve this?
- ctaylor6 years agoHelper III
Greg_Deckler
This solution is fantastic.I have a question though. This will allow incoming filters to change the output, but since it's the result of a temp table calculation what do I need to do to allow filters to be passed back out of a widget that is using the grouped up values? If I click on one of the groups in the widget using this formula, nothing else on the page gets filtered by the selection. Is there somehow a way to define a relationship back out, say...using the ID(s) that are contained in the selected group?
Attached image: Red box is using the grouping formula but the yellow boxed widgets are not being filtered by the selection in the red box. All widgets share a common unique identifier of PropertyID, which is included in the summarized data in the formula but cannot be filtered back out.
- Anonymous5 years agoNot applicable
Hi Greg_Deckler
Can you please guide me on my problem statement, i have posted on community. Please use below link:
https://community.powerbi.com/t5/Desktop/Partition-Measure-values-into-groups-and-change-dynamically-with/m-p/1842338Thanks
Sanchit
- TaariqHussain3 years agoHelper I
Hope you well
I tried using the above formula, please see below, need some assistance or maybe an alternative
I have 2 tables items sales and a second that has cost
both linked to master inventory
I have a measure that calculates my GP% however i want to group my GP's as per below
thats where your formula came in
Measure =VAR __Date = MAX('ItemWiseSales'[dateinvoiced])VAR __Category = MAX('Category'[Category])VAR __Low =SWITCH(__Category,"Less than 1%",-0.2,"1%",0.01,"2%",0.02,"3-5%",0.03,"5%>",0.05)VAR __High =SWITCH(__Category,"Less than 1%",0.01,"1%",0.019,"2%",0.029,"3-5%",0.049,"5%>",0.2)VAR __tmpTable = SUMMARIZE('ItemWiseSales',ItemWiseSales[itemprice],"__Percent",[GP%])RETURN COUNTROWS(FILTER(__tmpTable,[__Percent]>=__Low && [__Percent]<=__High))i than pull that measure into a pie chart but the visual is completely off