cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Avivek
Super User
Super User

Need help with the dax

I have a dax which is 

Total Procedures(TagLocation) =
SUMX (
    VALUES ( 'Tag Usage Fact'[Tag ID] ),
    CALCULATE (
        SUM ( 'Procedure Fact'[Procedures] ),
        --ALLEXCEPT ( 'Account Dim', 'Account Dim'[Account ID] ),
        ALLEXCEPT (
            'Tag Usage Fact',
            'Tag Usage Fact'[Tag ID]
        ),
        FILTERS ( 'Tag Usage Fact'[Order Date] ), FILTERS('Tag Usage Fact'[Tag Owner Name])
    )
)
 
This gives the desired results as well. But with this I am facing 2 problems, 
1. If i select the usage type as used/shared, total procedure should not be changing but it changes .
   Avivek_0-1660027404106.png

If I don't select Used/Shared then the column in total procedure is how it comes but if I select Used total procedure just show 1 line as total procedure changes to 3(it should have been still 23) and if I select Borrowed then total procedure changes to 20(it should have been still 23). I tried to change the dax to 

Test.Total Procedures(TagLocation) =
SUMX (
    VALUES ( 'Tag Usage Fact'[Tag ID] ),
    CALCULATE (
        SUM ( 'Procedure Fact'[Procedures] ),
        ALLEXCEPT (
            'Tag Usage Fact',
            'Tag Usage Fact'[Tag ID],'Tag Usage Fact'[Usage Type]
        ),
        FILTERS ( 'Tag Usage Fact'[Order Date] ), FILTERS('Tag Usage Fact'[Tag Owner Name])))
But then that gives me result as in last column Test.Total Procedure(TagLocation).
 
2. We have given % of Usage as is not 100%. 
Avivek_2-1660028147836.png

 

SO in this case ist tag id ie., 0001053 shows a total procedure as and % of usage as 50% but if I select that tag in the slicer then it shows blank

Avivek_4-1660028377039.png

 

This is because when selecting that tag on slicer it considers it as 1 single record and % of usage changes to 100% and total procedure changes to $ instead of 8 because it is taking only the borrowd procedure when the tag is selected.

% of Usage measure is 

% of Usage(tagLocation) = [No of Procedures]/[Total Procedures(TagLocation)]
 
Is there a way to resolve these 2 issues and what should be changed in both the dax.
1 ACCEPTED SOLUTION
RicoZhou2
Resolver I
Resolver I

Hi @Avivek ,

 

According to your statement, I think your problem is that you want to remove the filter from slicer in your visual. As far as I know, if the column in slicer is from same table or from a related table, Power BI will filter your visual by context. Here I suggest you to create unrelated dim tables to build slicer. And you can use SELECTEDVALUE() to catch single value or use VALUES() to catch multiple values in your measure.

If this reply still couldn't help you solve your problem, please share a sample file without sensitive data with us. And show us a screenshot with the result you want. This will make it easier for me to find the solution.

 

Best Regards.

View solution in original post

2 REPLIES 2
Avivek
Super User
Super User

Hi @RicoZhou2 , thankyou this works

RicoZhou2
Resolver I
Resolver I

Hi @Avivek ,

 

According to your statement, I think your problem is that you want to remove the filter from slicer in your visual. As far as I know, if the column in slicer is from same table or from a related table, Power BI will filter your visual by context. Here I suggest you to create unrelated dim tables to build slicer. And you can use SELECTEDVALUE() to catch single value or use VALUES() to catch multiple values in your measure.

If this reply still couldn't help you solve your problem, please share a sample file without sensitive data with us. And show us a screenshot with the result you want. This will make it easier for me to find the solution.

 

Best Regards.

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors