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
imadelmouden
Frequent Visitor

Mesure with complex filters

I am new to DAX, and I want to do a complex filter with it.
The thing is, I have a table :

TableA :

 

ID

PHONE (phone number of users)

TYPE_PHONE (contain either 0 or 1)
VOLUME_LTE

The phone number it may appear more than once in the table, so I want to count the numbers of users that has a type_phone = 0, and SUM of VOLUME_LTE also equal to 0.

in sql I use this :

Select phone from TableA
where type_phone = 0 and volume_lte = 0
group by phone;

1 ACCEPTED SOLUTION

... so you with your last edit.

 

May be this.

Measure =
CALCULATE (
    DISTINCTCOUNT ( Table2[PHONE] ),
    FILTER (
        Table2,
        SUMX (
            Table2,
            IF (
                SUM ( Table2[VOLUME_LTE] ) = 0
                    && Table2[TYPE_PHONE] = 0
                    && Table2[VOLUME_LTE] = 0,
                1,
                0
            )
        )
            > 0
    )
)

 

Using same sample table I showed before.

 

Result:

0.JPG

View solution in original post

6 REPLIES 6
Chihiro
Solution Sage
Solution Sage

Hmm, try following.

Measure =
SUMX (
    TableA,
    IF (
        SUM ( TableA[VOLUME_LTE] ) = 0
            && TableA[TYPE_PHONE] = 0
            && TableA[VOLUME_LTE] = 0,
        1,
        0
    )
)

With sample table like below.

0.JPG

 

Result:

1.JPG

 

@Chihiro by loocking in your example, it doesn't work, because 444111... has 0 in the two rows, but after the mesure it become 2 in total, I tried it and it does not work

Hmm? what's your condition then?

 

You had...

type_phone = 0 & volume_lte = 0 & where SUM of VOLUME_LTE = 0...

 

So... 441112222, has 2 records, and meets all criteria for both rows, i.e. 2.

 

Since, you updated sql try below then....

Measure 2 =
CALCULATE (
    COUNT ( [PHONE] ),
    FILTER ( Table2, Table2[TYPE_PHONE] = 0 && Table2[VOLUME_LTE] = 0 )
)

 

But do note 4441112222 will still return 2 (as per your SQL). 8005002000 will now also return 1.

@Chihiro I think I didn't explain enough, I don't want to count how many times the phone appear with those conditions, I want to count JUST the number that has 0 total volume summarized,

phone         volume_lte
99999999    45

44455555    0

55555555    15

44455555    0

55555555    0


So the output here is : 1 because the only number that has 0 volume in every row, is the 4445555
I hope I am clear now

... so you with your last edit.

 

May be this.

Measure =
CALCULATE (
    DISTINCTCOUNT ( Table2[PHONE] ),
    FILTER (
        Table2,
        SUMX (
            Table2,
            IF (
                SUM ( Table2[VOLUME_LTE] ) = 0
                    && Table2[TYPE_PHONE] = 0
                    && Table2[VOLUME_LTE] = 0,
                1,
                0
            )
        )
            > 0
    )
)

 

Using same sample table I showed before.

 

Result:

0.JPG

? Still isn't very clear to me what your requirement is.

 

May be upload sample data set, that mirror your data structure, along with manually counted/calculated expected output.

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.