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
Wedding55
Helper II
Helper II

Groupby with different calculations

Hello all,

 

i have a table with following measures:

 

digital: count of digital products per customer

offline: count of offline products per customer

total: count of total products per customer

 

Then i created a new column "typ" with the follwing expression:

 

type = SWITCH(TRUE(),
[count of digital products] = [count of total products], "online",
[count of offline products] = [count of total products], "offline",
"mix")
 
 Wedding55_2-1664536777548.png

 

but the problem is, that when i select the column "type" in the visual that for the customers with type "online" and "offline" i see two rows instead of one row with the type "mix". (see screenshot). 
Wedding55_1-1664536681655.png

 

For your information you can see the measures used for the digital, offline and total column:

 

digital= CALCULATE(DISTINCTCOUNT('Cases'[casenumber]), 'Cases'[organisation]="Org1", 'Cases'[tc]=1)

total = CALCULATE(DISTINCTCOUNT('Cases'[casenumber]), 'Cases'[tc]=1)

 offline = total - digital

 

Can anyone help me with the problem?

 

Best Regards

Henning

 

 
 

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Wedding55 ,

According to your description, I create a sample.

vkalyjmsft_0-1664774483818.png

And create measures like yours, finally get the correct result.

vkalyjmsft_1-1664774622600.png

May I know before you put "type" in the visual, is there a single row or two rows of customer 100204? If there're two rows, I think it's not the problem of "type".

Or you can try to modify the formula like this:

digital =
COUNTROWS (
    FILTER (
        ALL ( 'Cases' ),
        'Cases'[customer] = MAX ( 'Cases'[customer] )
            && 'Cases'[organisation] = "Org1"
            && 'Cases'[tc] = 1
    )
)
total =
COUNTROWS (
    FILTER (
        ALL ( 'Cases' ),
        'Cases'[customer] = MAX ( 'Cases'[customer] )
            && 'Cases'[tc] = 1
    )
)

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
Wedding55
Helper II
Helper II

@v-yanjiang-msft  Thanks for your help. Its works fine 🙂

v-yanjiang-msft
Community Support
Community Support

Hi @Wedding55 ,

According to your description, I create a sample.

vkalyjmsft_0-1664774483818.png

And create measures like yours, finally get the correct result.

vkalyjmsft_1-1664774622600.png

May I know before you put "type" in the visual, is there a single row or two rows of customer 100204? If there're two rows, I think it's not the problem of "type".

Or you can try to modify the formula like this:

digital =
COUNTROWS (
    FILTER (
        ALL ( 'Cases' ),
        'Cases'[customer] = MAX ( 'Cases'[customer] )
            && 'Cases'[organisation] = "Org1"
            && 'Cases'[tc] = 1
    )
)
total =
COUNTROWS (
    FILTER (
        ALL ( 'Cases' ),
        'Cases'[customer] = MAX ( 'Cases'[customer] )
            && 'Cases'[tc] = 1
    )
)

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Wedding55
Helper II
Helper II

Maybe this explanation helps:

 

I have 1 table:

 

casenumbercustomertype
1100084online
2100075offline
3100084offline
4100085online
5100085online

 

the result should look like this:

 

customertype
100075offline
100084mix
100085online

 

The special thing is to get the type "mix" because its not existing in the original table but if i have the same customer several times with different types i want in the result table only one row for this customer with the type "mix".

 

Thanks in advance 🙂

amitchandak
Super User
Super User

@Wedding55 , if these are measure then the below need to be a measure [count of digital products] , [count of total products],

 

type = SWITCH(TRUE(),
[count of digital products] = [count of total products], "online",
[count of offline products] = [count of total products], "offline",
"mix")

 

if you need this slicer or axis- follow the approach in this video

Customer Retention with Dynamic Segmentation, New/Lost/Retain Customer Count: https://www.youtube.com/watch?v=W4EF1f_k6iY

Hello amitchandak,

 

yes these are measures but my problem is the aggregation.

When i choose the column "type" and i have a customer with digital and offline cases then powerbi shows me two rows for one customer with type "online" and "offline". But in this cases i want one row with the type "mix". Do you understand my problem or should i explain it more detailed?

 

Best Regards

 

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.