Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
xxxvii
Regular Visitor

Help converting column DAX to a measure to use SelectedValue()

I've created a donut chart using the following column DAX:

 

 

is_EOSL = 
IF(ISBLANK(RELATED('model'[eosl_date])), "Unknown",
    IF(
        RELATED('model'[eosl_date]) > TODAY(),
        "No", "Yes"
    )
)

 

 

It works great when I use today's date hardcoded as TODAY(). However, I'd like to make that date dynamic (using SelectedValue()) where it would use a date selected in a slicer. My problem is that, the slicer will only work as intended on a measure.

 

Any ideas on how I could convert the above code to a measure as a first step to accomplishing my end goal? 

4 REPLIES 4
parry2k
Super User
Super User

@xxxvii Yes, you cannot use measures in the legend. Check this video on my channel and tweak the solution to fit your needs: Mastering Disconnected Tables - Use measures in slicers in Power BI | PeryTUS - Power BI How To - Yo...

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@xxxvii very hard to tell without knowing the model and how you want to visualize it, but try this

 

is_EOSL Measure = 
VAR __eos1_Date = MAX ( 'model'[eosl_date] )
VAR __SelectedDate = SELECTEDVALUE ( 'DateSlicer'[Date] )
RETURN
IF(ISBLANK(__eos1_Date ), "Unknown",
    IF(
        __eos1_Date  > __SelectedDate,
        "No", "Yes"
    )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

To convert the column to a measure, I actually had to create three seperate measures. Then I proceeded to adding all three measures to the Values section of my donut chart. That did the trick.

 

is_EOSL_NO = 
CALCULATE ( 
    COUNTROWS ( 'hardware_asset' ),
    NOT(ISBLANK('model'[eosl_date])) && 'model'[eosl_date] > TODAY()
)
is_EOSL_UNKNOWN = 
CALCULATE ( 
    COUNTROWS ( 'hardware_asset' ),
    ISBLANK('model'[eosl_date])
)
is_EOSL_YES = 
CALCULATE ( 
    COUNTROWS ( 'hardware_asset' ),
    NOT(ISBLANK('model'[eosl_date])) && 'model'[eosl_date] <= TODAY()
)

Good point. This is what the visual looks like right now using the calculated column. And the visualisation's properties. In the Legend, Status is the is_EOSL column that I referenced in my initial post. In the Values, Count of hardware_asset['asset_id'] is a count of asset_id from the fact table.

Phones.png

 

Visualisation's Properties.png

 

I was able to create the new measure using your code. The problem I'm facing now is, how to use the measure in my existing visual instead of the calculated column. I tried dragging the measure to Legend or Values in the visualization's properties, but it won't let me.

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors