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.
I'm looking for a solution for this case:
A user must be able to see anything from any other department, but when the reported opens by default it must only show his own department(s).
It seems to be not possible to just selected 1 value in a slicer (with all the usernames), based on the user(principal)name. So my alternative workaround is to create a slicer called 'Show only my own department'. This one must open with default selection 'Yes' and can only contain 'No' as other value; 1 value must always be selected. For this I use Chicklet Slicer. So far no problems; but now I need to filter a measure based on this slicer.
Current situation:
Report Slicer: Name: 'Show only my department'. Possible values: Yes or No.
Dataset: Name: Table_ProductionNumbers. Columns: User_Email, SoldItems, CustomerID.
Now I want this behaviour:
When 'No' is selected I want to see the total sum of solditems and the distinct count of CustomerID. When 'Yes' is selected I only want to see the sum of solditems that have a value in User_Email that is equal to the value of USERPRINCIPALNAME() and for the distinct count of CustomerID I also want to count the CustomerID's of records where User_Email equals USERPRINCIPALNAME().
(How) Can this be done in DAX? And is there also a possible solution which does not need some DAX for every measure, but does actually 'filter' the dataset in Table_ProductionNumbers? This makes it a lot more easy to add some more measures later on...
Solved! Go to Solution.
@MiKeZZa wrote:
Yes, I want exactly what you describe but then without placing a filter in the visual....
So I want every new added visual directly to lack the data that is filtered out in the visual with CustCount > 0 to prevent making mistakes by using the original measure's (I won't hide them)
Hi @MiKeZZa,
The method I can think out is to drag the CustCount to "Report level Filters" and set the value of it to be greater than 0.
Thanks,
Lydia Zhang
Likley would involve a measure calculation along the lines of:
IF(OnlyMyDept="Yes",calculate,calculate)
obviously psuedo-code, but that's the general idea.
I now have:
TestMeasure = IF(ShowOnlyMyDepartment="Yes",CALCULATE(COUNT(Table_ProductionNumbers[CustomerID])),CALCULATE(COUNT(Table_ProductionNumbers[CustomerID])))
I have 2 problems with this:
I've now made these Measures:
CustCountFiltered = CALCULATE(DISTINCTCOUNT(Table_ProductionNumber[CustomerID]), FILTER(TableProductionNumber, TableProductionNumber[User_Email]="mail@adress.com"))
DistinctCount(Table_productionNumber[CustomerID])
if(max(ShowOnlyDepartment_Slicer[OnlyOwnDepartment])="Yes",[CustCountFiltered],[CustCountNotFiltered])
This works well for now! The onliest thing is that I have to make something for the hardcoded mailadress. In PowerBI Desktop USERPRINCIPALNAME() doesn't work; the filtered values are empty then. But I'll give it a try after publishing.
This all works fine. So I'm happy now. But the onliest thing I'm interested now is if there is a possiblity to automatically filter the whole dataset. This because of that I now have to filter a table with CustCount > 0.
Hi @MiKeZZa,
Could you please describe more details about automatically filtering the whole dataset? We will appreciate that if you can share sample data of your tables and post expected result here.
If you want to filter data with “CustCount>0”, just drag the measure to the visual level filter of your table visual and set the value of the measure to be greater than 0.
Thanks,
Lydia Zhang
Yes, I want exactly what you describe but then without placing a filter in the visual....
So I want every new added visual directly to lack the data that is filtered out in the visual with CustCount > 0 to prevent making mistakes by using the original measure's (I won't hide them)
@MiKeZZa wrote:
Yes, I want exactly what you describe but then without placing a filter in the visual....
So I want every new added visual directly to lack the data that is filtered out in the visual with CustCount > 0 to prevent making mistakes by using the original measure's (I won't hide them)
Hi @MiKeZZa,
The method I can think out is to drag the CustCount to "Report level Filters" and set the value of it to be greater than 0.
Thanks,
Lydia Zhang
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |