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
klittle95
Regular Visitor

visualization table will only use unique values

I'm fairly new to Power BI, so it's entirely possible the solution to this is staring me in the face, but I've been working on it since yesterday and I'm out of ideas.

I'm trying to calculate how much money an animal hospital is making over time. I have two very simple tables:

table3.PNGtable4.PNG

As you can see, together they show what procedures were performed over the last month and how much each costs. I have confirmed that they share a relationship based on ProductID:

relationship.PNG

 

All I want is to show how much money they made each month. But when I put the price and date into the same visualization table while making the report, the math is all wrong. I have to leave the day in the table, otherwise some of the rows appear to be duplicates, and the table only counts them once.

Even that doesn't work for the two instances of a procedure costing $15 occurring on January 30th; it only appears once in the table and the math is off accordingly.

I get the closest if I set the Price field to Sum and leave in the days. That way the individual rows are correct. But it totals incorrectly and cannot be used in a line chart. You can see that it seems to think the total is $162, where it should be $732 ($717 in January, $15 in February).

I cannot imagine why using only unique values should be the default. If I go back to the query editor and merge the tables, it works perfectly, but that completely defeats the purpose of having relationships at all.

various tables.PNG

1 ACCEPTED SOLUTION

You were on the right track--the working code:

Working Price = CALCULATE (  SUMX('ProceduresHistory-1', Related(ProceduresDetails[PD-Price])))

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @klittle95,

 

Please try to add below measure into table visual together with date field.

Sum Price =
CALCULATE (
    SUM ( Table1[T3-price] ),
    USERELATIONSHIP ( Table1[ProcedureID], Table2[ProcedureID] )
)


Regards,

Yuliana Gu

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

Hi @v-yulgu-msft,

 

I created 

Sum Price = 
CALCULATE (
    SUM ( Table3[T3-price] ),
    USERELATIONSHIP ( Table3[ProcedureID], Table4[ProcedureID] )
)

inside Table3 and added it to each table visual. In every case, it produces the same numbers as Table3[T3-Price] did. 

The same thing happens if I create the measure inside Table4.

You were on the right track--the working code:

Working Price = CALCULATE (  SUMX('ProceduresHistory-1', Related(ProceduresDetails[PD-Price])))

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.