Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
Please assist me with this DAX measure I'm trying to calculate the sum of inventory based on the countries for a selected user.
I have attached my pbix file with the measure called "TotalInventoryProcessedForSelectedUserCountries"
I'm trying to get the total for all users which had the same countries with inventory as Ann where from 25 April to 1 May 2020 Ann had inventory in 6 countries (Brazil,Canada,Ireland,Mexico,US and Venezuela). I need the total inventory for all users who had inventory in those same 6 countries. My measure now returns all users and all countries but I need only the selected user's countries.
PBIX file link - https://www.dropbox.com/s/5rxhb0ajieqwzyj/TableFilter.pbix?dl=0
My DAX code :=
Solved! Go to Solution.
Hey @Anonymous ,
I think I found an easier way.
First I get the countries for the current user and then I just use that list as a filter for calculate.
Check the following approach:
TotInventory =
-- Get all countries for the current user
VAR vCountries =
CALCULATETABLE(
VALUES( data[Country] ),
ALLEXCEPT(
data,
data[User Name]
)
)
RETURN
-- return the [SumOfInventoryProcessed] and we use
-- as only filter the countries from the first step
CALCULATE(
[SumOfInventoryProcessed],
vCountries,
ALL( data )
)
Thank you it worked 🙂
Hey @Anonymous ,
I think I found an easier way.
First I get the countries for the current user and then I just use that list as a filter for calculate.
Check the following approach:
TotInventory =
-- Get all countries for the current user
VAR vCountries =
CALCULATETABLE(
VALUES( data[Country] ),
ALLEXCEPT(
data,
data[User Name]
)
)
RETURN
-- return the [SumOfInventoryProcessed] and we use
-- as only filter the countries from the first step
CALCULATE(
[SumOfInventoryProcessed],
vCountries,
ALL( data )
)
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
22 | |
11 | |
10 | |
10 | |
8 |