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
Anonymous
Not applicable

how to create a summary table

i have data as below

PKbatchstatus
11progress
12comp
13comp
14comp
15progress
21progress
22progress
23null
31progress
32progress
33progress
41progress
42progress
43progress
44progress
45progress
46progress

 

 

I would like to filter each PK for max batch and create an output as below

 

col1 has 3 because it is concerned with status progress and null both

col2 has 2 because it is concerned with status progress only

col3 has 1 because it is concenred with status null only

 

col1col2col1
321

 

 

Please provide suggestions/inputs. I am a new user

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Well, the code above return for your understanding is correct. Before I explain the return part of the code, you may need to understand the SWITCH function first.

The return part is to choose from three different situations:

If the 'status'[status] column is equal to "progress / null", then it counts the situation of [status] = "progress" or [status] = "null" in the t2 table.

If the 'status'[status] column is equal to "progress ", then it counts the situation of [status] = "progress" in the t2 table.

If the 'status'[status] column is equal to "null", then it counts the situation of [status] = "null" in the t2 table.

 

I use Enter data to create the status table. And I created the status table to display my measures.

enter.png

 

 

Best Regards,

Icey

 

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

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

My understanding is this:

1. You want to filter the max batch of each PK. The result is below:

PK batch status
1 5 progress
2 3 null
3 3 progress
4 6 progress

 

2. Count the number of progress, null, progress or null. The result is below:

progress / null progress null
4 3 1

 

 

If my understanding is right, try this:

1. Enter data to create a seperate status table and sort [status] column by [order] column.

status.jpg

 

2. Create a measure:

Count Measure = 
VAR t =
    ADDCOLUMNS (
        'Table',
        "MaxBatch", CALCULATE ( MAX ( 'Table'[batch] ), ALLEXCEPT ( 'Table', 'Table'[PK] ) )
    )
VAR t2 =
    FILTER ( t, [batch] = [MaxBatch] )
RETURN
    SWITCH (
        MAX ( 'status'[status] ),
        "progress / null", COUNTROWS ( FILTER ( t2, [status] = "progress" || [status] = "null" ) ),
        "progress", COUNTROWS ( FILTER ( t2, [status] = "progress" ) ),
        "null", COUNTROWS ( FILTER ( t2, [status] = "null" ) )
    )

count.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

Could you explain the code? Mainly the return part?

I understand that in the table Table, you are creating a column MaxBatch and then filtering Table. 

 

how did you create the Status table?

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Well, the code above return for your understanding is correct. Before I explain the return part of the code, you may need to understand the SWITCH function first.

The return part is to choose from three different situations:

If the 'status'[status] column is equal to "progress / null", then it counts the situation of [status] = "progress" or [status] = "null" in the t2 table.

If the 'status'[status] column is equal to "progress ", then it counts the situation of [status] = "progress" in the t2 table.

If the 'status'[status] column is equal to "null", then it counts the situation of [status] = "null" in the t2 table.

 

I use Enter data to create the status table. And I created the status table to display my measures.

enter.png

 

 

Best Regards,

Icey

 

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

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.