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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dax-Measure return column/data if count ...

Hello fellow PowerBi users,

 

right now i have a column in a table, which i dragged into a "card". So depending on (clicking on a custom diagram) it filters out all the unneeded rows and just shows data from some rows.

But if i dont click anything/dont have any filter applied i want to show nothing instead of the first value of the column. So i wanted to use a measure, but i am not sure how to create it exactly. I thought of something like this:

----------------------------------

Measure=

VAR _count = COUNTROWS(Table)

Return

if( _count>10, " ", Table(Description) )

-----------------------------------

(or maybe MAX or Concatentate before Table(Description) before it so it isnt a "naked" column reference) but it doesnt work eighter. 

 

So my question is: How do i show all aggregated data of one filtered column in one cell together in a card, but if its unfiltered and has more then a certain amount of rows (10) it doesnt show anything?

 

(but if sombody has an idea what i did wrong at my basic attempt without the aggregation i would be thankful as well)

 

Thank you a lot:)

Strathos

 

1 ACCEPTED SOLUTION

Hi  @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a measure as below:

Measure = 
VAR _count =
    COUNTROWS ( ALLSELECTED ( 'Table' ) )
VAR _combinedtext =
    CONCATENATEX ( VALUES ( 'Table'[Description] ), 'Table'[Description], "," )
RETURN
    IF ( NOT ( ISFILTERED ( 'Table'[Item] ) ) || _count > 10, BLANK (), _combinedtext )

yingyinr_0-1652758379411.png

yingyinr_2-1652758529191.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
PC2790
Community Champion
Community Champion

You can make use of HASONEFILTER- 

https://docs.microsoft.com/en-us/dax/hasonefilter-function-dax

 

If(HasOnefilter( Table(Description)),Countrows(Table),Blank())

Anonymous
Not applicable

thx, didn't know that, but sadly it doesn't work as the visual doesn't apply a real filter that PowerBi can detect, it just temporarily removes the rows somehow.

So i still have to do it with the COUNTROWS function somehow.

PC2790
Community Champion
Community Champion

If you want to show blank if row count increases 10, you cna try this:

Noofrows = 
var _count = CALCULATE(CountRows(ALLSELECTED(Table)))
return
if(_count>10,BLANK(),_count)
Anonymous
Not applicable

i am sry to bother you again, but with this it only shows the var _count if the rows are less then 10. How do i do it to give back the value (text) from the "filtered" rows of column Table[Description] itself ?

((or the text of all rows showing of the column combined))

Hi  @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a measure as below:

Measure = 
VAR _count =
    COUNTROWS ( ALLSELECTED ( 'Table' ) )
VAR _combinedtext =
    CONCATENATEX ( VALUES ( 'Table'[Description] ), 'Table'[Description], "," )
RETURN
    IF ( NOT ( ISFILTERED ( 'Table'[Item] ) ) || _count > 10, BLANK (), _combinedtext )

yingyinr_0-1652758379411.png

yingyinr_2-1652758529191.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.