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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
chetan8080
Helper I
Helper I

Create a measure Based on Visual values

I need to create a measure where it gives me 1 or 0 based on values in a matrix visual,

chetan8080_0-1747728858626.png

In the above picture the first two yellow highlighted values are unique in the matrix should have 1 as result rest others should get 0,
These values are not unique in the table backend, these get repeated in the table, The measure should ignore the table and just check values from the visual and give results.
Basically it should check rows in the visual and those rows which have unique ID should give 1 as result or else 0
Thank you in advance

2 ACCEPTED SOLUTIONS

Hi @chetan8080,


I have used sample data and implemented the solution in Power BI Desktop. Please have a look."

 

Try this DAX Measure:

Unique In Visual =
VAR CurrentValue = SELECTEDVALUE(Sheet1[Value])
VAR VisibleRows =
    SUMMARIZE(
        ALLSELECTED(Sheet1),
        Sheet1[ID],
        Sheet1[Value]
    )
VAR CountVisible =
    COUNTROWS(
        FILTER(
            VisibleRows,
            [Value] = CurrentValue
        )
    )
RETURN IF(CountVisible = 1, 1, 0)
 
I have included the PBIX file that I created using the provided sample data. Kindly review it and confirm whether it aligns with your expectations.

 

I hope my suggestions provided valuable insights. If you have any further questions, don’t hesitate to ask in a follow-up message.
If this post helped, please mark it as "Accept as Solution" so others can benefit as well.

 

Best regards,
Sahasra
Communtiy Support Team.

View solution in original post

Hi @chetan8080,

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided

 

Need help uploading data?How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Thank you.

View solution in original post

8 REPLIES 8
chetan8080
Helper I
Helper I

Hello @SolomonovAnton , thank you for replying,
See below pictures where the ID is repeating but still DAX Returns me 1 instead of 0

chetan8080_0-1747736596750.png

chetan8080_1-1747736735984.png

The dax should  give 1 only when the ID is unique in the visual, if it gets repeated it should give 0.


Thanks,
Chetan J

 

Hi @chetan8080,


I have used sample data and implemented the solution in Power BI Desktop. Please have a look."

 

Try this DAX Measure:

Unique In Visual =
VAR CurrentValue = SELECTEDVALUE(Sheet1[Value])
VAR VisibleRows =
    SUMMARIZE(
        ALLSELECTED(Sheet1),
        Sheet1[ID],
        Sheet1[Value]
    )
VAR CountVisible =
    COUNTROWS(
        FILTER(
            VisibleRows,
            [Value] = CurrentValue
        )
    )
RETURN IF(CountVisible = 1, 1, 0)
 
I have included the PBIX file that I created using the provided sample data. Kindly review it and confirm whether it aligns with your expectations.

 

I hope my suggestions provided valuable insights. If you have any further questions, don’t hesitate to ask in a follow-up message.
If this post helped, please mark it as "Accept as Solution" so others can benefit as well.

 

Best regards,
Sahasra
Communtiy Support Team.

Hi @v-sgandrathi ,
thank you for your response.
I tried your solution but it does not work for big data, please see attached image,

chetan8080_1-1747840986929.png

 

First 4 rows are giving the correct results, the following rows even after having same ID and different PO gives false.
The false expectation in this dax is as shown in this image below which is incorrectly showing true

chetan8080_2-1747841100601.png

 

Hi @chetan8080,

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided

 

Need help uploading data?How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Thank you.

Hi @chetan8080,

 

I wanted to check if you had the opportunity to follow up on our previous conversation. If yes can you please provide the sample data so that we can provide you with the accurate and correct solution. 

Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.

 

Thank you.

Hi @chetan8080,

 

I wanted to check if you had the opportunity to follow up on our previous conversation. If yes can you please provide the sample data so that we can provide you with the accurate and correct solution. 

Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.

 

Thank you.

HI @chetan8080,

 

Can you please confirm whether you have resolved issue. If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. This will be helpful for other community members who have similar problems to solve it faster. 

If we don’t hear back, we’ll go ahead and close this thread.Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread. We’ll be happy to help.

 

Thank you.

SolomonovAnton
Solution Sage
Solution Sage

To achieve a measure that evaluates uniqueness *based on what's displayed in the matrix visual* (ignoring backend duplicates), you can use the DAX function ISINSCOPE along with COUNTROWS and FILTER on visible data using ALLSELECTED.

Here’s a measure that does this:

Unique In Visual =
VAR CurrentValue = SELECTEDVALUE('YourTable'[ID])
VAR CountVisible = 
    CALCULATE(
        COUNTROWS('YourTable'),
        FILTER(
            ALLSELECTED('YourTable'),
            'YourTable'[ID] = CurrentValue
        )
    )
RETURN IF(CountVisible = 1, 1, 0)

🧩 How it works:

  • SELECTEDVALUE: Gets the current row value in the matrix.
  • ALLSELECTED: Limits calculation to only what's visible in the matrix (not the whole table).
  • FILTER + COUNTROWS: Counts how many times that value appears in the visual.
  • IF = 1: Means the value appears only once = unique in visual.

📌 Usage Tip:

Add this measure to your matrix visual along with the ID and check the output. The measure will return 1 for unique IDs in the visual and 0 for repeated ones.

📚 Reference:

✔️ If my message helped solve your issue, please mark it as Resolved!

👍 If it was helpful, consider giving it a Kudos!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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