Forum Discussion

Jeff2Jets's avatar
Jeff2Jets
Helper III
1 year ago
Solved

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 \Calend...
  • wardy912's avatar
    1 year ago

    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!

  • Sandip_Palit's avatar
    1 year ago


    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.