# Calculate the sum of a filtered measure

Hi,

First post, I will try to be clear.
I am trying to calculate levies. The levies are calculated by market share x licence fees paid (aka the SAC)

So SAC x Market Share = Levy paid.
with a floor charge of \$50.

So I have done two measures as follows:

[Levy = floor] = IF( [Levy] < 50, 50, BLANK()) // Levies paying floor

[Levy > floor] = IF( [Levy] > 50, [Levy], BLANK()) // Levies paying > floor

Now I want to sum the levies that are paying \$50.00, and those that are paying more, to get two separate amounts.

It is late, but I am getting confused at why a measure canâ€™t just show me the total value when I drag in a card.

Perhaps I should be doing this all in code and variables?

Thanks in advance for any assistance.

It would help if you could post your PBIX file to see if Iâ€™m missing anything here, but based on your description above I think all you need to do is create two more measures that calculate the sum of your [Levy=floor] and [Levy>floor] measures. Then you can drop those two new measures into cards to show the respective totals.

If your question is how to get the proper totals for each column in your table visual, please take a look at posts #11 and #14 in this topic, where I walked through this in detail with another member.

• Brian

Here is my pbix

I am trying to work out the sum of all the levy that equal 50
And then the sum of the others.

So that I can create a new market share for those who do not pay the minimum floor levy, subtract the total of those that pay the minimum floor from the total to be recovered (31.1 mill) and then apportion to those that are not paying the floor amount by the new market share.

Models - JG - 12.10.19.pbix (1.3 MB)

Essentially, I want to do this in PBI as here is Excel.
data1.csv (997.2 KB)

So that I can apportion things out so they donâ€™t pay more than the total recovery, due to the floor minimum charge.

I hope this makes sense.

Total recovery amount through levy = 35.1â€¦ million

Thanks very much for posting the files. However, the CSV file you posted does not correspond to the PBIX. I think you meant post an Excel file instead. If thatâ€™s the Excel file that you used to bring the data into Power BI, can you please post that?

This shouldnâ€™t be difficult, but Iâ€™m getting some funky results on the calculations branching off the >\$50 measure that I want to check against the original data in Power Query to figure out whatâ€™s going on.

Thanks.

• Brian

Hi Brian,
You are very patient. Thank you. The files are over 4MB (one 11MB the other about 5MB) so I cut things down, but that likely added to confusion.

Here are the originals:

Thank you so much for you time. I feel this should be easy, but am hitting brick walls.

Thanks again.
John

I just had a thought, perhaps I could create a supporting table like

Group Min Max
Min payers 0 50
Other payers 50 100000000000000

and then play around with that, so that in essence I categorise each line.

hmmmm.

Whew! This one was much harder to crack than I expected. As you and I were both thinking, this seemed like it should have been pretty straightforward. However, there were two problems buried deep that were throwing the numbers off:

1. Your Licensee lookup was creating a circular reference that was throwing off crazy numbers (\$92 Billion in one measureâ€¦). In the tables and cards, I used the Data[Licensee] field instead, and got rid of the one column lookup table.
2. you had a column AND a measure both called â€śAnnual SACâ€ť, and one was used in the wrong place somewhere . I renamed the measure [Total Annual SAC] and corrected the reference.

In the screenshot below, the cards in blue represent the adjusted levies, employing the \$50 floor. The orange are the unadjusted levies, with â€ślowâ€ť corresponding to <= \$50, and â€śhighâ€ť being above \$50.

I hope this gets you what you need. Best,

• Brian
1 Like

Amazing trouble shooting. You are very talented. I will take a close look and hopefully learn much from it. Thank you so much for your time and accepting the challenge, especially when there were model issues that you identified.

I would have never got there alone.

Many thanks
John

I have to ask what EQ and GT stand for. It is killing me.

Equals and Greater Than.

In the early stages of trying to figure out what was going on, I thought maybe the use of = or > in a measure name was causing problems, so I renamed them to rule that out.

I should have started looking for model problems earlier than I did. When fairly basic DAX throws out crazy results, itâ€™s almost always a problem with the data model.

• Brian

Ahhhh. Funny. EQ GT.

I donâ€™t understand what was wrong with taking the licensees out of the data table and using them as a lookup table with = VALUES(Data[Licencee]), but perhaps that wasnâ€™t the issue?

You mentioned a circular reference? Is that referring to the above? Should I not use VALUES(
to create a unique lookup list in models?

and this is a structure and formula of beauty â€¦ thanks.

Thanks. I was trying to figure out how much of an increase in levies you achieved by setting the floor amount, and that construct ended up working out well.

Per your earlier question, generally, I donâ€™t think you will want to use VALUES() on your fact tables to create lookup tables. That is where the circular reference problem came from. I couldnâ€™t get the error to replicate in a different PBI report I tested, but the interesting thing is that if you take the original file you sent me, delete the relationship to that lookup table, and then try to add it back in, PBI wonâ€™t let you do it because of the circular reference problem. However, the error message that it throws out is not super helpful beyond identifying it as a circular reference:

I think the safer way to accomplish the same thing is to do it in Power Query: