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
Saxon202202
Helper III
Helper III

Measure Issue in visual table

Hi,

I have a two tables; Data and Report. The data table contains unique value, while the report table has duplicate entry, Both tables have a many-to-one releationship. Because of this relationship, I can drag the necessary columns (State, Id, Qty and Type) from the data table into the report table in the visual table.

I want to create a measure for a visual table that evaluates the Stock and Qty columns from the Data and Report tables based on the Item column. The measure should display 'Yes' if the Stock value is greater than or equal to the Qty value; otherwise, it should display 'No'.

I tried using the following measure to achieve this, but I encountered an error (please refer to the attached snapshot)


Saxon202202_0-1741822303973.png


Desired Result: (I prepare manually)

Saxon202202_1-1741822575140.png

Record NumberItemNameStateBinStockStatus
72170123-01Tyre-01CHEGEN011000Not Okay
78521123-01Tyre-01RCBGEN02500Ok
63476123-02Tyre-02CHEGEN031000Ok
80012123-02Tyre-02CHEGEN045000Not Okay
78123123-03Tyre-03CHEGEN0550Ok
45211123-05Tyre-05RCBGEN0650Not Okay
70234123-05Tyre-05RCBGEN0780Not Okay
74897123-10Tyre-10RCBGEN08150Ok


Attached the Power BI file for your reference.

https://www.dropbox.com/scl/fi/emaip6z0cyyps5jyg9m2t/Table_Visual1.pbix?rlkey=eu1ts7b40k5356t07xdl9t...


 

1 ACCEPTED SOLUTION
v-karpurapud
Community Support
Community Support

Hi @Saxon202202 

Welcome to the Microsoft Fabric Forum,

Also thank you all for responding on this topic.
 

Regarding the measure to compare Stock and Qty values, the issue arises due to the many-to-one relationship between the Data and Report tables. When you pull non-aggregated fields (such as Qty) from the Data table, Power BI attempts to display all matching combinations based on the relationship.
 

In your case, the Item "123-01" in the Report table has two entries, while the Data table may contain multiple corresponding Qty values for the same item. As a result, Power BI cross-joins each matching Qty with the related Report rows, leading to duplicate lines in the visual.

 

In Power BI, row duplication occurs when non-aggregated columns are pulled from the "one" side of a many-to-one relationship, where the "one" side contains multiple matching rows.

 

To evaluate each record in the Report table individually without aggregation and to avoid duplicate lines, you should create a calculated column in the Report table.

 

Try using  the LOOKUPVALUE function as follows:

 

Comparison =

VAR DataQty = LOOKUPVALUE(Data[Qty], Data[Item], Report[Item])

RETURN

    IF(Report[Stock] >= DataQty, "Yes", "No")

 

If this information helps resolve your issue, kindly consider marking this response as the Accepted Solution, as it may assist other community members facing similar challenges.

 

Thank you for being part of the Microsoft Fabric Community.

 

View solution in original post

18 REPLIES 18
v-karpurapud
Community Support
Community Support

Hi @Saxon202202 

I wanted to check if you had the opportunity to review the information provided. 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 and give a 'Kudos' so other members can easily find it.

Thank you.

@v-karpurapud, I am really sorry for the late reply. Usually I received email notification but some reason I didn't received it. Thanks for your reply and support. 

v-karpurapud
Community Support
Community Support

Hi @Saxon202202 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @Saxon202202 

Welcome to the Microsoft Fabric Forum,

Also thank you all for responding on this topic.
 

Regarding the measure to compare Stock and Qty values, the issue arises due to the many-to-one relationship between the Data and Report tables. When you pull non-aggregated fields (such as Qty) from the Data table, Power BI attempts to display all matching combinations based on the relationship.
 

In your case, the Item "123-01" in the Report table has two entries, while the Data table may contain multiple corresponding Qty values for the same item. As a result, Power BI cross-joins each matching Qty with the related Report rows, leading to duplicate lines in the visual.

 

In Power BI, row duplication occurs when non-aggregated columns are pulled from the "one" side of a many-to-one relationship, where the "one" side contains multiple matching rows.

 

To evaluate each record in the Report table individually without aggregation and to avoid duplicate lines, you should create a calculated column in the Report table.

 

Try using  the LOOKUPVALUE function as follows:

 

Comparison =

VAR DataQty = LOOKUPVALUE(Data[Qty], Data[Item], Report[Item])

RETURN

    IF(Report[Stock] >= DataQty, "Yes", "No")

 

If this information helps resolve your issue, kindly consider marking this response as the Accepted Solution, as it may assist other community members facing similar challenges.

 

Thank you for being part of the Microsoft Fabric Community.

 

danextian
Super User
Super User

If there is an existing relationship between the two tables, you can just compare the aggregates.

Comparison = 
VAR _ReportStock =
    SUM ( Report[Stock] )
VAR _DataQty =
    SUM ( Data[Qty] )
RETURN
    IF ( _ReportStock > _DataQty, "Yes", "No" )

danextian_0-1741863773800.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks for your reply.
Could you please share the PBI file, some reason still I am getting lot of duplicate lines.

Here it is.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi,

Thank you for your response. I would like to display the status for each individual line in the report table, so I want to avoid summing the Stock and Qty columns.

Is it possible to achieve the desired outcome without aggregating Stock and Qty for each line in the report table?
Could you also clarify how removing the aggregation (e.g., sum) for the Qty column might lead to the generation of multiple rows in the report table?

Saxon202202_0-1741868482340.png

 

 Desired Result:

Saxon202202_0-1741869048143.png

 

 

You can choose not to summarize Data[Qty] and Report[Stock] columns but would it, in your case, make sense to compare the Qty of each item in Data against individual rows in Report?

danextian_0-1741870869779.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes please. I like to know the status each individual rows. 

Desired results :

Saxon202202_0-1741871366360.png

 

Add the qty and stock columns but don't summarize them.

.danextian_0-1741871601822.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes, I did. I apply do not summary of qty and stock columns in visual table but it's showing lot duplicate columns for the same line. Could you please explain why it's returned so many duplicates lines.

In report table 123-01 has two lines only. 

Ashish_Mathur
Super User
Super User

Hi,

In that PowerBI file, show the expected result very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for your reply. 

Column name "Status" is my desired result (Please refer the snapshot)

Saxon202202_0-1741837213895.png

 

Deku
Community Champion
Community Champion

Var stock = sum( report[stock] )

Var qty = sum( data[qty] )

Return

If( qty <= stock, "yes", "no")

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Hi, Thanks for your reply. I would like included item as well in the measure. Also, I would like to get the status each lines rather than sum of the qty. 

 

Deku
Community Champion
Community Champion

When included in a table with the item field present the sums will be per item as all the field for that row form a filter context for the measure


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

I try to apply your measure and it's generate lot of duplicated lines. (Refer the snapshot)

Saxon202202_0-1741824403227.png

Any idea why it's generting ultiple rows? Please

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.