Forum Discussion
Convert Tableau LOD calculation into Power BI
count grp =
var _year = SELECTEDVALUE(Datetable[Year])
var _acountgrp = CALCULATE(DISTINCTCOUNT(LOCATIONS[LOCATION_NUM]),Datetable.[Year] = _year)
RETURN SWITCH(TRUE(),
_acountgrp = 0, "no Locations",
_acountgrp = 1, "1 Location",
_acountgrp <= 5, "2-5 Locations",
_acountgrp <= 10, "6-10 Locations",
_acountgrp <= 20, "11-20 Locations",
"20+ Locations")
Thank you so much for the response! The above calculation is a measure however i cant add measure to the rows right in a matrix table. if you look at the tableau report screenshot that is attached in the beginning on this post, it has count grp (group category) on the rows based on the condition. in the screenshot which is attached to this message i created a table "Locations" with just one column (Group) having 5 rows using "Enter Data " with the count grp (group categories) and to this when i drag the measure which you shared it is returning "no locations" which is group category name but ideally it should be returning distinct count of "wholesale Parent Name". Is there a way to create the group category name with If, else statement by distinct counting the field 'wholesale parent name?' Please let me know if you need further clarifications
- lbendlin3 years agoSuper User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523