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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sjelting
Frequent Visitor

How to use Text column in Measure without aggregating

I have a data table with a date and text column. there are multiple rows for the same date. I want to display the rows in a table visual filtered on date. this works well, but I also want to have a "default" filter if no filter on date column is set.

 

For that i would need to create a measure which uses IF(ISFILTERED(date...), ...) but measures need to return 1 row instead of multiple.

 

What is the solution in such a case?

1 ACCEPTED SOLUTION

Hi @sjelting ,

 

Please try:

Measure = 
IF (
    NOT ISFILTERED ( 'Table'[Column1] ),
    IF (
        MAX ( 'Table'[Column2] ) IN { "c", "d" },
        MAX ( 'Table'[Column1] ),
        BLANK ()
    ),
    IF ( ISFILTERED ( 'Table'[Column1] ), MAX ( 'Table'[Column1] ) )
)

 

The final visual effect is shown below:

vhuijieymsft_0-1713343362316.png

vhuijieymsft_1-1713343404194.png

vhuijieymsft_2-1713343404195.png

vhuijieymsft_3-1713343419218.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

6 REPLIES 6
v-huijiey-msft
Community Support
Community Support

Hi @sjelting ,

 

Thanks for the reply from @Sahir_Maharaj .

 

I am a little vague about your needs. You mentioned "IF(ISFILTERED(date...), ...)". What do you want to return if the result is TRUE? FalseWhat do you want to return?

 

You mentioned having multiple rows for the same date, but the measure needs to return 1 row instead of multiple rows. What is the row that needs to be returned?

 

I would be grateful if you could provide me with your expected results.

 

I would be grateful if you could provide me with sample data for testing, please remove any sensitive data in advance.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

i cant upload a sample pbix , so i will add a screenshot:


sjelting_0-1713259460873.png

 

Hi @sjelting ,

 

Please try:

Measure = 
IF (
    NOT ISFILTERED ( 'Table'[Column1] ),
    IF (
        MAX ( 'Table'[Column2] ) IN { "c", "d" },
        MAX ( 'Table'[Column1] ),
        BLANK ()
    ),
    IF ( ISFILTERED ( 'Table'[Column1] ), MAX ( 'Table'[Column1] ) )
)

 

The final visual effect is shown below:

vhuijieymsft_0-1713343362316.png

vhuijieymsft_1-1713343404194.png

vhuijieymsft_2-1713343404195.png

vhuijieymsft_3-1713343419218.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

This measure uses the values hard coded., but they change over time, so that is no solution 

sjelting
Frequent Visitor

this wont work as it shows only one line if a filter is set even though there might be multiple rows and only the default text if its not set.

Sahir_Maharaj
Super User
Super User

Hello @sjelting,

 

Can you please try this:

Is Date Filtered = IF(ISFILTERED(TableName[Date]), "Filtered", "Not Filtered")
Display Text = 
VAR isFiltered = [Is Date Filtered]
RETURN
IF(
    isFiltered = "Filtered",
    MAX(TableName[TextColumn]), 
    "Default Text"
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors