The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I am trying to visualize country column data from the Customer dimension using the filled map
I have a slicer from CostCenter[Name] and need to reflect country data in the map. Due to the inactive relationship between Person and Customer, I am using Userelationship and writing the following measure to include the Location field for the Map instead Country column directly from the Customer dimension.
But I am getting the following error. Please help me to rewrite the measure. The above relationships I could not change to active since I have other facts and dimensions that might lead to circular relations so I need to work with measure to be inactive only.
The error you're encountering in your DAX measure likely stems from the inactive relationship between Person and Customer. Here's how you can rewrite the measure to address this issue:
1. Using VAR with LOOKUPVALUE:
The error you're encountering in your DAX measure likely stems from the inactive relationship between Person and Customer. Here's how you can rewrite the measure to address this issue:
1. Using VAR with LOOKUPVALUE:
Filled Map Measure = VAR SelectedCostCenter = SELECTEDVALUE(CostCenter[Name]) VAR CustomerTable = FILTER( Customer, RELATED(Person[CostCenterName]) = SelectedCostCenter ) VAR Location = LOOKUPVALUE( Customer[Location], Customer[CustomerID], RELATED(Customer[CustomerID]) ) RETURN IF( ISBLANK(Location), BLANK(), Location )
Explanation:
2. Using CALCULATE with TREATAS:
The error you're encountering in your DAX measure likely stems from the inactive relationship between Person and Customer. Here's how you can rewrite the measure to address this issue:
1. Using VAR with LOOKUPVALUE:
Filled Map Measure = VAR SelectedCostCenter = SELECTEDVALUE(CostCenter[Name]) VAR CustomerTable = FILTER( Customer, RELATED(Person[CostCenterName]) = SelectedCostCenter ) VAR Location = LOOKUPVALUE( Customer[Location], Customer[CustomerID], RELATED(Customer[CustomerID]) ) RETURN IF( ISBLANK(Location), BLANK(), Location )
Explanation:
2. Using CALCULATE with TREATAS:
Filled Map Measure = VAR SelectedCostCenter = SELECTEDVALUE(CostCenter[Name]) VAR ActiveCustomerTable = CALCULATE( Customer, TREATAS( Person[CostCenterName], SelectedCostCenter ) ) VAR Location = SUMX( ActiveCustomerTable, ActiveCustomerTable[Location] ) RETURN Location
Explanation:
Both options achieve the same outcome: they filter the customer data based on the selected cost center and return the corresponding location for the map visualization. The choice between them might depend on your preference and coding style.
Remember:
I hope this helps!
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Thank for your reply.
https://drive.google.com/file/d/1dx8Q08o_351S_jAXavWmMPlGPVzfhkEo/view?usp=drive_link
I have tried both measures and there are small problems could you please check the sample data and measure implementation
Replace VALUES with MAX
Thank you very much for your reply. Now I got only one city instead CostCenter has many customer countries how an I get all coutries when filtered from CostCenter and get Customer Countries to give as input to the Location in the filled map.
Measure Customer Country = CALCULATE(
MAX ( Customer[Country] ),USERELATIONSHIP
(Person[Id],Customer[Id]))
Right now even though I tried to give this as input the filled map Location it is not acceptable by the visual.
Switch from USERELATIONSHIP to TREATAS
I tried to post pbix file but I could not able to find an option to attach here.To be more clear I have slicer from CostCenter on the Level field and I posted the data model and map again to be clear and I cannot change he relationships as I have other dimentions and facts which might effect.
I used above measure to rectify the issues but still getting the same error as below
Not sure how to rectify with treatas. Please help me further if any of you can suggest any further views
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Thanks for the reply. Please find the link to google drive
https://drive.google.com/file/d/1NnevayBggtZJ86QNvVl-rQUj-TSi-nFA/view?usp=drive_link
I have included sample data, measure "country" in the measure table and I tried to give measure to the map Location in the data section and it is not acceptable.
User | Count |
---|---|
65 | |
61 | |
60 | |
53 | |
30 |
User | Count |
---|---|
181 | |
88 | |
71 | |
48 | |
46 |