Forum Discussion

rogelep's avatar
rogelep
Regular Visitor
3 months ago
Solved

Using SelectedValue in measure for computing volume

Hello,

 

Need help in setting up a measure that counts the number of rows that have a date that is selected in a slicer.

I used these measures:

SelectedDate = selectedvalue('Complaints Raw Data'[Date Received]) //to store the date selected in the measure

Volume = calculate(count('Complaints Raw Data'[short_id]),'Complaints Raw Data'[Date Received] = [SelectedDate]) //should count number of rows that have the same date as the selected date in the slicer
 
However, i'm getting the error message "A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."
 Any clarification or tips on this matter would be highly appreciated.
  • The fix is to move the SELECTEDVALUE inside the measure using a VAR:

    Volume =
    VAR _SelectedDate =
        SELECTEDVALUE ( 'Complaints Raw Data'[Date Received] )
    RETURN
        CALCULATE (
            COUNT ( 'Complaints Raw Data'[short_id] ),
            'Complaints Raw Data'[Date Received] = _SelectedDate
        )
  • Hi,

    Create a Calendar table and have a *:1 relationship from the Date received column to the Calendar table.  To your slicer, drag the Date from the Calendar table.  Write this measure

    Volume = count('Complaints Raw Data'[short_id])

    Hope this helps.

     

7 Replies

  • Hi rogelep,

     

    Try below DAX

     

    Volume =
    VAR SelectedDt =
    SELECTEDVALUE(
    'Complaints Raw Data'[Date Received]
    )
    RETURN
    CALCULATE(
    COUNT('Complaints Raw Data'[short_id]),
    FILTER(
    ALL('Complaints Raw Data'),
    'Complaints Raw Data'[Date Received] = SelectedDt
    )
    )

     

    OR

     

    Volume =
    VAR SelectedDt =
    SELECTEDVALUE(
    'Complaints Raw Data'[Date Received]
    )
    RETURN
    CALCULATE(
    COUNT('Complaints Raw Data'[short_id]),
    TREATAS(
    {SelectedDt},
    'Complaints Raw Data'[Date Received]
    )
    )

     

    ๐ŸŒŸ I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
    ๐Ÿ’ก Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
    ๐ŸŽ– As a proud SuperUser and Microsoft Partner, weโ€™re here to empower your data journey and the Power BI Community at large.
    ๐Ÿ”— Curious to explore more? [Discover here].
    Letโ€™s keep building smarter solutions together!

  • Rahul_Vyas's avatar
    Rahul_Vyas
    Regular Visitor

    Hi,

    The error occurs because CALCULATE's filter arguments must be Boolean column expressions or table expressions โ€” you cannot directly reference a measure (like [SelectedDate]) inside a filter predicate. DAX doesn't allow Column = Measure as a direct filter argument.

    Volume =
    CALCULATE(
    COUNT('Complaints Raw Data'[short_id]),
    FILTER(
    'Complaints Raw Data',
    'Complaints Raw Data'[Date Received] = [SelectedDate]
    )
    )
    ====
    FILTER() returns a table, which CALCULATE accepts. Inside FILTER, the row-by-row evaluation resolves the measure correctly.

    Hope this gets you moving in the right direction! If it solved your problem, hitting 'Mark as Solution' helps others find the answer faster. Kudos are always appreciated too โ€” they go a long way in keeping this community thriving.

    I'm always happy to help. Don't hesitate to reach out if you have more questions!

  • Hi rogelep 

    Why do you need to use a filtered measure when you're using the same column from the same table? You could simply use 'Complaints Raw Data'[Date Received] in a slicer and count('Complaints Raw Data'[short_id]) in a measure.

  • The fix is to move the SELECTEDVALUE inside the measure using a VAR:

    Volume =
    VAR _SelectedDate =
        SELECTEDVALUE ( 'Complaints Raw Data'[Date Received] )
    RETURN
        CALCULATE (
            COUNT ( 'Complaints Raw Data'[short_id] ),
            'Complaints Raw Data'[Date Received] = _SelectedDate
        )
  • Hi,

    Create a Calendar table and have a *:1 relationship from the Date received column to the Calendar table.  To your slicer, drag the Date from the Calendar table.  Write this measure

    Volume = count('Complaints Raw Data'[short_id])

    Hope this helps.

     

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi rogelep ,

    Thank you Ashish_Mathur , cengizhanarslan , danextian , grazitti_sapna  for your inputs.
    Weโ€™d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

    Thank you.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi rogelep ,

    May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.

    Thank you.