1
votes

I have a table (named Proto) in power-bi desktop as shown below (with 4 columns & around 30k rows). enter image description here

I created a measure with the following DAX code. Here, ProtoVal is a table of single column containing unique values of protocol (like SSL, DNS etc). Based on the user selected protocol, i am filtering the above table to contain rows only for the selected protocol.

ProtoTotBytes =
VAR SelectedProto = SELECTEDVALUE(ProtoVal[Protocol])
VAR temp1 = FILTER(Proto, Proto[Protocol] == SelectedProto)
RETURN CALCULATE(SUM(Proto[total_bytes]), temp1)

The above DAX code works fine. Now in addition to SelectedProto, i wanted to add one more config variable numIP (TopN-IP's being a table of single column containing numerical values 5,10,15,20 etcTopN-IP's = GENERATESERIES(5, 30, 5)) where i want to take only the top 'numIP' rows from table temp1. Wrote the code below for that. This works whenever i change the value of SelectedProto but doesn't change when i change numIP ? Can anyone please let me know whey its sensitive to one config variable while it is ignoring another ?

ProtoTotBytes =
VAR numIP = SELECTEDVALUE('TopN-IP''s'[TopN-IP's])
VAR SelectedProto = SELECTEDVALUE(ProtoVal[Protocol])
VAR temp1 = FILTER(Proto, Proto[Protocol] == SelectedProto)
VAR temp2 = TOPN(numIP, temp1, [total_bytes], DESC)
RETURN CALCULATE(SUM(Proto[total_bytes]), temp2)
1
Where from numIP coming?mkRabbani
@mkRabbani : updated the question above. numIP is the selected value coming from TopN-IP's which is a table of single column containing numerical values 5,10,15,20 etcmezda

1 Answers

0
votes

It does exactly what you told it to do, look at your code:

VAR temp1 = FILTER(Proto, Proto[Protocol] == SelectedProto)
VAR temp2 = TOPN(numIP, temp1, [total_bytes], DESC)

in the first line you use FILTER, this is correct, you are filtering in the second line you are using TOPN, this is only sorting. I believe your intent was, was a filter based on your selection so also here you need to use FILTER.

VAR temp2 = FILTER(temp1, numIP = VALUE(RIGHT(Proto[networkIpAddress],1)))

In this filter I compare the last digit of the networkIp with the numIP(s) selected by the user