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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
fenneran
New Member

Divide With a Sum and Filter on same column

I am new to PowerBI and have searched the forum, which has been very helpful, but I'm stuck on what I think is a very simple task, but the results are not as expected.

 

I have a Filtered, Grouped table of phone call records with the following columns:

  • User Name
  • Date
  • Direction (True/False)
  • Count (count of rows based on the grouping of the above three fields)

I want to come up with a percentage of incoming calls (direction = false) to outgoing calls (direction = true) and have the following calculation:

 

CallBack = DIVIDE( CALCULATE(sum('Raw Calls'[Count]), 'Raw Calls'[DirectionCode]=FALSE()) , CALCULATE(sum('Raw Calls'[Count]), 'Raw Calls'[DirectionCode]=TRUE()) )

 

It does not give an error, but when I put it into a "Card" visulization, the result is "Blank"

 

So I thought I could create two variables: Incoming and Outgoing, then just divide those.  The formulas for those were:

Incoming = CALCULATE(sum('Raw Calls'[Count]), 'Raw Calls'[DirectionCode]=FALSE())

Outgoing = CALCULATE(sum('Raw Calls'[Count]), 'Raw Calls'[DirectionCode]=TRUE())

 

The first one creates just fine, but when I create the second on I get a circular reference error.

 

What am I doing wrong?

 

-Frank

2 ACCEPTED SOLUTIONS
Sean
Community Champion
Community Champion

@fenneran That error indicates you are creating COLUMNS! Convert them to MEASURES!

 

Try this MEASURE!

It basically just adds zero to the one you've already created but adding zero is by far the easiest way to handle blank in a card!

 

CallBack =
DIVIDE (
    CALCULATE ( SUM ( 'Raw Calls'[Count] ), 'Raw Calls'[DirectionCode] = FALSE () ),
    CALCULATE ( SUM ( 'Raw Calls'[Count] ), 'Raw Calls'[DirectionCode] = TRUE () ),
    0
)
    + 0

View solution in original post

Greg_Deckler
Community Champion
Community Champion

I can't simulate your grouping and filtering but here is what I did:

 

Using this Enter Data query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSi9KTVfSUTI00AciIwNDMyDHLTGnOBVIGynF6mBXEVJUClJgDFaQlJmTg8sI3CqgRpii22GIbgRuFVAjDA3QLcEww9AQpxKYIUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"User Name" = _t, Date = _t, Direction = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User Name", type text}, {"Date", type date}, {"Direction", type logical}, {"Count", Int64.Type}})
in
    #"Changed Type"

 

I created the following measure that returned the correct result:

 

CallBack = VAR Incoming = CALCULATE(SUM([Count]),ALL('Raw Calls'),'Raw Calls'[Direction]=FALSE())
VAR Outgoing = CALCULATE(SUM([Count]),ALL('Raw Calls'),'Raw Calls'[Direction]=TRUE())
RETURN Incoming/Outgoing


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
fenneran
New Member

Thank you both, that is exactly what I needed.  I know it was something simple!

 

Best,

Frank

Greg_Deckler
Community Champion
Community Champion

I can't simulate your grouping and filtering but here is what I did:

 

Using this Enter Data query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSi9KTVfSUTI00AciIwNDMyDHLTGnOBVIGynF6mBXEVJUClJgDFaQlJmTg8sI3CqgRpii22GIbgRuFVAjDA3QLcEww9AQpxKYIUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"User Name" = _t, Date = _t, Direction = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User Name", type text}, {"Date", type date}, {"Direction", type logical}, {"Count", Int64.Type}})
in
    #"Changed Type"

 

I created the following measure that returned the correct result:

 

CallBack = VAR Incoming = CALCULATE(SUM([Count]),ALL('Raw Calls'),'Raw Calls'[Direction]=FALSE())
VAR Outgoing = CALCULATE(SUM([Count]),ALL('Raw Calls'),'Raw Calls'[Direction]=TRUE())
RETURN Incoming/Outgoing


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Sean
Community Champion
Community Champion

@fenneran That error indicates you are creating COLUMNS! Convert them to MEASURES!

 

Try this MEASURE!

It basically just adds zero to the one you've already created but adding zero is by far the easiest way to handle blank in a card!

 

CallBack =
DIVIDE (
    CALCULATE ( SUM ( 'Raw Calls'[Count] ), 'Raw Calls'[DirectionCode] = FALSE () ),
    CALCULATE ( SUM ( 'Raw Calls'[Count] ), 'Raw Calls'[DirectionCode] = TRUE () ),
    0
)
    + 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.