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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PoornimaV
New Member

Convert Tableau LOD calculation into Power BI

Can anyone help me to rewrite the below Tableau calculation into Power BI please? I have tried below PBI calculation but it doesnt return the desired outout. I have also attached tableau report screenshot for better understanding what the calculation looks like

 

Tableau SS2.PNG

 

 Tableau Calculation:

Count Group = {fixed [Wholesale Parent],YEAR([Post DATE]),[Location Sub Type] :IF countd([Location#]) = 1
THEN '1 Location'
ELSEIF countd([Location#]) > 1 AND COUNTD([Location#])<= 5
THEN '2-5 locations'
ELSEIF countd([Location#]) > 5 AND COUNTD([Location#]) <=10
THEN '6-10 locations'
ELSEIF countd([Location#]) > 10 and COUNTD([Location#]) <= 20
THEN '11 - 20 Locations'
ELSE
'20+ Locations'
END }

 

Power BI Calculation:

count grp =
var _year = CALCULATE(SELECTEDVALUE(Datetable[Year]))
var _acountgrp = CALCULATE(DISTINCTCOUNT(LOCATIONS[LOCATION_NUM]),FILTER(Datetable,Datetable[Date].[Year] = _year))
var _group = CALCULATE(SELECTEDVALUE('Location Group'[Group]))

RETURN

IF(AND(_acountgrp = 1, _group = "1 Location"), _acountgrp,
IF(AND(_acountgrp > 1, _acountgrp <= 5 &&  _group = "2-5 Locations"), _acountgrp,
IF(AND(_acountgrp > 5, _acountgrp <= 10 && _group = "6-10 Locations"), _acountgrp,
IF(AND(_acountgrp > 10, _acountgrp <= 20 && _group = "11-20 Locations"), _acountgrp,
IF(AND(_acountgrp > 20, _group = "20+ Locations"),_acountgrp )
3 REPLIES 3
lbendlin
Super User
Super User

 

 

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 clarificationsss7.PNG

 

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-...
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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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
Top Kudoed Authors