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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Jeff2Jets
Helper II
Helper II

Using CALCULATE to summarize different values

I have two tables. The first 'Folders' has the following columns/values:

 

Folder Name       Items

\Calendar                  2

\Calendar                  3

\Calendar                  4

\Calendar\Birthdays  5

\Calendar\Holidays   6

\Drafts                       7

 

The second 'Folders Summary' has the following:

 

Folder Name

\Calendar

\Drafts 

I want to add the column 'Items' to the 'Folders Summary' table and I want a formula (e.g., CALCULATE?) that will create the following values:

 

\Calendar          20

\Drafts                7

 

So the formula would sum the values for all rows that are '\Calendar' or start with '\Calendar\'.

 

Is that possible?

6 REPLIES 6
v-tejrama
Community Support
Community Support

Hi @Jeff2Jets ,

Thanks for reaching out to the Microsoft fabric community forum.

 

I tested this scenario and successfully achieved the result the OP was looking for. There are two tables: the Folders table, which lists folder names such as \Calendar, \Calendar\Birthdays, \Drafts, etc., along with item counts; and the Folders Summary table, which contains only the top-level folder names like \Calendar and \Drafts.

 

The goal was to calculate the total item count for each summary folder, including all subfolders that start with that name. For instance, \Calendar should aggregate items from \Calendar, \Calendar\Birthdays, and \Calendar\Holidays.

 

To accomplish this, I created a measure in the Folders Summary table using the following DAX:

 

Total Items =
CALCULATE (
    SUM ( 'Folders'[Items] ),
    FILTER (
        ALL ( 'Folders' ),
        LEFT ( 'Folders'[Folder Name], LEN ( SELECTEDVALUE ( 'Folders Summary'[Folder Name] ) ) )
            = SELECTEDVALUE ( 'Folders Summary'[Folder Name] )
    )
)

 

Please find the attached pbix file for your reference.
Best Regards,
Tejaswi.
Community Support

 

 

Hi @Jeff2Jets ,

 

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you.

 

Thank you.

 

Hi @Jeff2Jets ,

 

I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.

 

Thank you.

 

Hi @Jeff2Jets ,

 

I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.

Thank you,

Tejaswi.

 

Sandip_Palit
Resolver II
Resolver II


1. Go to the 'Folders Summary' Table
In Power BI's Data View, select the 'Folders Summary' table from the Data pane on the right.

2. Create a New Column
From the Table tools ribbon at the top, click New column.

3. Enter the DAX Formula
In the formula bar, enter the following DAX expression. This formula calculates the sum for each folder in your summary table.

Items =
VAR CurrentFolder = 'Folders Summary'[Folder Name]
RETURN
CALCULATE (
SUM ( 'Folders'[Items] ),
FILTER (
'Folders',
'Folders'[Folder Name] = CurrentFolder
|| STARTSWITH ( 'Folders'[Folder Name], CurrentFolder & "\" )
)
)
After you press Enter, the new Items column will be populated with the correct totals.

 

If this explanation and solution resolve your issue, please like and accept the solution.

wardy912
Impactful Individual
Impactful Individual

Hi @Jeff2Jets 

Try this:

Items = 
CALCULATE(
    SUM(Folders[Items]),
    FILTER(
        Folders,
        LEFT(Folders[Folder Name], LEN('Folders Summary'[Folder Name])) = 'Folders Summary'[Folder Name]
    )
)

 

Please give a thumbs up and mark as solved if it helps, thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors