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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
nok
Advocate II
Advocate II

Create a table with unique IDs and calculations based on the original table

Hi!

I have a table that follows this structure:

IDBalance   Type   Date
111   10A20/10/2025  
11120M30/10/2025
2225A02/12/2025
2223B01/09/2024
33340M23/11/2024
33330M27/05/2025
33321A21/09/2025
4449B17/03/2025

 

I want to create a new calculated table based on the original that displays distinct IDs, sum of Balance for each ID, columns with the count of rows for each type, and the maximum date for each ID and type.
The end result would be a table like this:

IDBalance  Count
(Type A)   
Max Date
(Type A)
Count
(Type B)   
Max Date
(Type B)
Count
(Type M)   
Max Date
(Type M)
111   30120/10/2025          0 130/10/2025   
2228102/12/2025101/09/2024    0 
33371121/09/20250 227/05/2025
44490 117/03/20250 


How can I do this?

1 ACCEPTED SOLUTION
Gabry
Super User
Super User

Hey,

try to make a calculated table with this dax

 

SummaryByID :=
ADDCOLUMNS(
    SUMMARIZE(
        'Fact',
        'Fact'[ID],
        "Balance", CALCULATE(SUM('Fact'[Balance]))
    ),
    // Type A
    "Count (Type A)",     CALCULATE(COUNTROWS('Fact'), 'Fact'[Type] = "A"),
    "Max Date (Type A)",  CALCULATE(MAX('Fact'[Date]), 'Fact'[Type] = "A"),
    // Type B
    "Count (Type B)",     CALCULATE(COUNTROWS('Fact'), 'Fact'[Type] = "B"),
    "Max Date (Type B)",  CALCULATE(MAX('Fact'[Date]), 'Fact'[Type] = "B"),
    // Type M
    "Count (Type M)",     CALCULATE(COUNTROWS('Fact'), 'Fact'[Type] = "M"),
    "Max Date (Type M)",  CALCULATE(MAX('Fact'[Date]), 'Fact'[Type] = "M")
)

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

If you are OK with a measure based solution, then write these measures

Total = sum(Data[Balance])

C = calculate(countrows(Data),data[type]="A")

D = max(Data[Date])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Gabry
Super User
Super User

Hey,

try to make a calculated table with this dax

 

SummaryByID :=
ADDCOLUMNS(
    SUMMARIZE(
        'Fact',
        'Fact'[ID],
        "Balance", CALCULATE(SUM('Fact'[Balance]))
    ),
    // Type A
    "Count (Type A)",     CALCULATE(COUNTROWS('Fact'), 'Fact'[Type] = "A"),
    "Max Date (Type A)",  CALCULATE(MAX('Fact'[Date]), 'Fact'[Type] = "A"),
    // Type B
    "Count (Type B)",     CALCULATE(COUNTROWS('Fact'), 'Fact'[Type] = "B"),
    "Max Date (Type B)",  CALCULATE(MAX('Fact'[Date]), 'Fact'[Type] = "B"),
    // Type M
    "Count (Type M)",     CALCULATE(COUNTROWS('Fact'), 'Fact'[Type] = "M"),
    "Max Date (Type M)",  CALCULATE(MAX('Fact'[Date]), 'Fact'[Type] = "M")
)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.