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
Anonymous
Not applicable

Sum Values Based on Multiple Entries from Multiple Columns

Hi, I have a table as shown below:

 

Device IDDaySubtotal
Device01December 1st10
Device01December 1st30
Device01December 1st15
Device02December 1st10
Device02December 1st5
Device01December 2nd10
Device01December 2nd20
Device02December 2nd10
Device02December 2nd30
Device02December 2nd5

 

I need to add the subtotals based on device ID and day. The dates and subtotals will update daily to include the most recent data.

 

So my desired end result is as follows:

 

Device IDDayTotal
Device01December 1st55
Device02December 1st15
Device01December 2nd30
Device02December 2nd45

 

Then I need to make a stacked bar chart per device with total as the y axis and date as the x axis (not sure if this changes the approach to the solution)

 

I appreciate any help!


Thanks,

2 ACCEPTED SOLUTIONS
smpa01
Super User
Super User

@Anonymous you can use a measure like this

Measure= CALCULATE(SUM(tbl[Subtotal]), ALLEXCEPT(tbl,tbl[Device ID],tbl[Day]))

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

smpa01
Super User
Super User

@Anonymous  when all the axis comes form Scanner Stats

Measure =
CALCULATE (
    SUM ( ScannerStats[Subtotal] ),
    ALLEXCEPT ( ScannerStats, ScannerStats[DeviceId], ScannerStats[Date] )
)

when axis come from different tables

Measure2 =
CALCULATE (
    SUM ( ScannerStats[Subtotal] ),
    VALUES ( ScannerStats[DeviceId] ),
    VALUES ( DateTable[Date] )
)

 

smpa01_0-1639068762172.png

 

pbix is attached

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

13 REPLIES 13
smpa01
Super User
Super User

@Anonymous  when all the axis comes form Scanner Stats

Measure =
CALCULATE (
    SUM ( ScannerStats[Subtotal] ),
    ALLEXCEPT ( ScannerStats, ScannerStats[DeviceId], ScannerStats[Date] )
)

when axis come from different tables

Measure2 =
CALCULATE (
    SUM ( ScannerStats[Subtotal] ),
    VALUES ( ScannerStats[DeviceId] ),
    VALUES ( DateTable[Date] )
)

 

smpa01_0-1639068762172.png

 

pbix is attached

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Yes that is the same that I'm getting in my original model. The issue is that the measure isn't actually showing the sum by day.


For example, December 1st shows 29 under Measure 2 in "Axis from different tables". When the value I'm acutally looking for is 440 for December 1st. As you can see below 29 is just the first value in the table

 

Sum By Day .png

 

Thanks.

 

Anonymous
Not applicable

@smpa01 thanks for the response! Unfortunately it's still showing it by individual record per day rather than sum per day. The chart below is filtered by a single device ID.

DeviceID Stacked Bar.png

 

Any other suggestions?

@Anonymous  check attached

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Ashish_Mathur
Super User
Super User

Hi,

To your matrix visual, drag Device ID and Day to the Row well.  Write this measure

Total = sum(Data[Subtotal])

Hope this helps.


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

@Anonymous you can use a measure like this

Measure= CALCULATE(SUM(tbl[Subtotal]), ALLEXCEPT(tbl,tbl[Device ID],tbl[Day]))

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@smpa01 Thanks for the attachment. I see that it works on yours so I marked it as the correct solution, but I still see this on mine:

 

Device ID Chart.png

 

The sum on the first row is correct, but then when it breaks it down by day, it's showing the first entry in the data rather than summing all the data per day:

 

Device Data.png

 

Is this possibly because I'm using a date table? I've tried removing the date table and using the date from the original table but that doesn't work either. This is my measure:

 

Measure.png

 

I really appreciate your help on this.

 

 

@Anonymous  please prepare a sample pbix, upload in g/1 drive and please share the link

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Access denied

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@Anonymous  just to be clear, you want to bring axis from two different tables?

Device Id from ScannerStats and Date from DateTable?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Yes that is correct. 

I do have a date field in ScannerStats as well which didn't seem to work with your provided solution, but if it works for you I wouldn't mind using it

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.