Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Adding a slicer from different columns; calculating sum based on values in other columns

Hello, I have the following example table containing data about some products:         I want to make a report and I struggle with some issues: - I would like to have a slicer for Period...
  • vivran22's avatar
    6 years ago

    Hello Anonymous 

     

    For the first problem, I would recommend you to transform your table using Power Query:

     

    Unpivot your value columns:

     

    Split the Attribute column(earlier headers) to create two separate columns:

     

     

    This way you should be able to filter your visuals using slicers:

     

     

     

    For the % share, it is not very clear what is the output you are looking for. Is this the output you are looking for?

     

    I have created following measures for this:

     

     

    Total fruits =
    CALCULATE (
        SUMX ( dtTable, IF ( dtTable[Category] = "fruits", dtTable[Value] ) ),
        ALLEXCEPT ( dtTable, dtTable[Category] )
    )
    
    
    Total Vegetables =
    CALCULATE (
        SUMX ( dtTable, IF ( dtTable[Category] = "Vegetables", dtTable[Value] ) ),
        ALLEXCEPT ( dtTable, dtTable[Category] )
    )
    
    
    % Share fruits = DIVIDE(SUM(dtTable[Value]),[Total fruits])
    
    % Share Vegetables = DIVIDE(SUM(dtTable[Value]),[Total Vegetables])

     

     

    You may find the solution pbix file here

     

    Regards,
    Vivek

    If it helps, please mark it as a solution

    Kudos would be a cherry on the top 🙂

    https://www.vivran.in/