Forum Discussion

SteveG_91's avatar
SteveG_91
Helper I
3 years ago
Solved

Force Legend Not To Affect DAX measure

I have a table named “Created Apps” that contains applications that have been created.  Within that table is a column named “Action”.  One of the possible values for that column is “R”.  On the “R” records there will be a value in another column, named “Table”.  It looks like this.

 

APP_NUMBERACTIONTABLE
X1S 
X2R01
X3D 
X4R05
X5R06
X6S 
X7D 
X8R05
X9R05
X10R01

 

I’m trying to show the value of each unique “Table” as a percent of the Action = R records.  So Table 01 = 33% (2/6), 05 = 50% (3/6), 06 = 17% (1/6).  I want to plot this on a line graph to show the monthly trend over time, with a separate line for each Table

 

The issue I’m having is that when I use the measure to the visual and I add the Table as a legend it makes every value 100% because the legend is affecting both the numerator and denominator.  I want it to only affect the numerator.  I tried REMOVEFILTERS but that only works against a slicer.  How can I force it so the legend only affects the numerator in my divide measure?

  • KNP's avatar
    KNP
    3 years ago

    I don't have enough info about your model, relationships and name of the date field you're using, but you likely need to change the measure to something like this...

     

    D = 
    CALCULATE (
        [CA],
        ALLSELECTED ( YourDateColumnName )
    )

     

    If that doesn't work, I'll need some additional detail to figure it out.

     

4 Replies

  • KNP's avatar
    KNP
    Super User

    If I understand correctly, the measures below will work.

     

    CA = 
    CALCULATE (
        COUNTROWS('Created Apps'),
        FILTER (
            'Created Apps',
            'Created Apps'[TABLE] <> ""
        )
    )

     

    D = 
    CALCULATE (
        [CA],
        ALL ( 'Created Apps' )
    )

     

    % = 
    DIVIDE (
        [CA],
        [D],
        BLANK ()
    )

     

    • SteveG_91's avatar
      SteveG_91
      Helper I

      That's close.  The issue now is that while the denominator is not affected by the legend, as I was hoping, it is also not affected by the date that is on the X axis of my line chart.  So if over the last 12 month there were 10,000 created applications it is using 10,000 as the denominator for every month.  The numerator uses the correct monthly count but the denominator does not.

      • KNP's avatar
        KNP
        Super User

        I don't have enough info about your model, relationships and name of the date field you're using, but you likely need to change the measure to something like this...

         

        D = 
        CALCULATE (
            [CA],
            ALLSELECTED ( YourDateColumnName )
        )

         

        If that doesn't work, I'll need some additional detail to figure it out.