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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
VulcanPromance
Helper II
Helper II

Calculate issue

Ok.. So I have this project that involves 3 tables. Employees, Licenses, Cost

Employees contain

IDNameCompanyCountry
1EricTest1 IncNorway
2PeterTest2 CorpSweden
3JohnTest3 ASDenmark


License contain

IDLicense Type
1Helpdesk
2Helpdesk
3Workorder
1Reception
2Workorder
3

Reception

 

And Cost contain

CategoryLicense TypeQuantity TypePrice
ServiceHelpdeskTotal425
ServiceReceptionpr license47
FacilityWorkorderpr license47


I've created a custom column on Employee based on company to create Country.

The goal here is to be to click on a map, and get the amount of licenses for each country and show the cost pr license type monthly in .f.ex a table form like this.

CategoryLicense TypeQuantity TypePriceCountMonthly
ServiceHelpdeskTotal4252425
FacilityWorkorderpr license47294


The count is a calculated column which goes to Licenses table to fetch distinct values

Count =
CALCULATE(
DISTINCTCOUNT(Licenses[ID]);
ALLEXCEPT(Cost;Cost[License Type])
)


Now when I click the country in the map it shows the correct license types in that country,
but it still show the count of the entire world of that particular license type.

And if I add the monthly cost column it shows cost for global license cost. Not for the country selected.
 
I tried to create a count based on measures
Count pr Country2 =
CALCULATE(
DISTINCTCOUNT(Licenses[ID]);
ALLEXCEPT(Employees;Employees[Country])
)
 Which made the count actually work. But Monthly costs still wont work. Even if I use the measure for calculating
Monthly Cost = IF(Cost[Quantity Type]="pr License";(Cost[Count pr Country2])*Cost[Price];(Cost[Price])*1)
 
Im pretty new to this stuff, and I cant seem to find any post here that lets me understand why this happens. Or how to fix it.. Hope someone can help.
 
1 ACCEPTED SOLUTION
AnthonyTilley
Solution Sage
Solution Sage

i have created a PBIX file that may be what you want 

 

PBIX File

 

you dont not want to use a distinct count of the id becuase the id in itself is not unique. just use a count

 

map.png

 

this file has a sheet that alows you to do what you asked click on one of the countrys and the table to the right will show the brakedown of the number of licences by type with a count and a sum of the price based on the quantity type 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @VulcanPromance 

Modify with AnthonyTilley's pbix, create measures instead of calculated columns (columns are static while measures are dynamic)

Count = 
CALCULATE(DISTINCTCOUNT(Licenses[License Type]),ALLSELECTED(Licenses))

Measure = 
Var ty = max(Cost[Quantity Type])
var co = count(Licenses[ID])
Var sw = SWITCH(ty,"TOTAL",sum(Cost[Price]),Sum(Cost[Price])*[Count])
Var bl = if(co = blank(),BLANK(),sw)
return bl

14.png

You can add [measure] is not blank in the visual level filter for the table visual, so final result can be

15.png16.png


Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AnthonyTilley
Solution Sage
Solution Sage

i have created a PBIX file that may be what you want 

 

PBIX File

 

you dont not want to use a distinct count of the id becuase the id in itself is not unique. just use a count

 

map.png

 

this file has a sheet that alows you to do what you asked click on one of the countrys and the table to the right will show the brakedown of the number of licences by type with a count and a sum of the price based on the quantity type 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors