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
xierwee
Helper I
Helper I

create measure to pivot data

 

Hi, I am a newbee in power bi.  I have the following data in table 1. I would like to create a measure to calculate the sum of  two names selected by slicers. for each date, and then plot the result in a line chart. For instance, when I select A and B through slicer. 

 

the result should be table 2. I know in the matrix, one can some how get the table, but I couldn't find a way to plot it. Please help me, ideal case is not to use matrix. Thanks a lot in advance.

 

table 1

 

datenamevalue
20180101A0.1
20180101B0.1
20180101C0.2
20180101D0.4
20180102A0.1
20180102B0.2
20180102C0.1
20180102D0.5
20180103A0.1
20180103B0.3
20180103C0.4
20180103D0.1

 

 

table 2

datetotal
201801010.2
201801020.3
201801030.4

 

1 ACCEPTED SOLUTION

Hi @xierwee 

 

You may try below measure:

Measure =
DIVIDE (
    SUM ( Table1[value] ),
    CALCULATE ( SUM ( Table1[value] ), ALLSELECTED ( Table1[name] ) )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
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

4 REPLIES 4
HotChilli
Super User
Super User

I think you could probably do this without writing any DAX because the default behaviour of powerbi would be to sum the value field in any visualisation.

But if you want more control -     Measure = SUM(Table1[value])

 

Create the slicer and change the options to allow multi-selection.

Make sure the Date field has the correct Date type

you are totally correct! Woman Happy thank you!

 

Another question, if I want to divide the sum? like in table3, what should the measure look like, I tried the divide. 

 

datenamestotal
20180101A50.00%
20180101B50.00%
20180102A33%
20180102B67%
20180103A25%
20180103B75%

Hi @xierwee 

 

You may try below measure:

Measure =
DIVIDE (
    SUM ( Table1[value] ),
    CALCULATE ( SUM ( Table1[value] ), ALLSELECTED ( Table1[name] ) )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

cool, thank you very much!

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.