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
pak
Helper II
Helper II

Summing values in column from the mark in other column

Hello everyone,

 

I'm begginer with Power BI and i need your help 🙂

 

This is my problem:

I must sum overal WorkTime of the machine but after repair the WorkTime must be sumed from zero. So i added in the machine  button that is pressed after repair. When it's pressed the Mark bit (1) is send to ASA.
In Power BI Desktop i dont have tables, only fields and measures. I get my data from ASA.
But i added table that show you what i mean.

 

 

Date and TimeWorkTimeMark
2017-12-12 16:00:00120 
2017-12-12 16:00:10122 
2017-12-12 16:00:20 1
2017-12-12 16:00:30125 
2017-12-12 16:00:40  
2017-12-12 16:00:50111 
2017-12-12 16:01:00123 
2017-12-12 16:01:10112 
2017-12-12 16:01:20123 
2017-12-12 16:01:301451
2017-12-12 16:01:40156 
2017-12-12 16:01:50125 
2017-12-12 16:02:00  
2017-12-12 16:02:10123 
2017-12-12 16:02:20121 
2017-12-12 16:02:30113 
2017-12-12 16:02:40  
2017-12-12 16:03:00154 

 

So in the raport i want to see sum of WorkTime from the moment where Mark = 1.
for example:

If there's 16:01:20 , and i'm refreshing raport i should get value 594.
If there's 16:03:00 , and i'm refreshing raport i should get value 792.

 

This would be very helpfull 🙂

7 REPLIES 7
pak
Helper II
Helper II

Anyone??

The thing is i need it tommorow 😕

Hey @pak

 

I worked on the solution but was unable to match the 2nd data result you gave and seems like there was typo at your end.

 

Here is how you can achieve it:

 

Add Rank column

 

 

Rank = 
RANKX(Filter(Machine, Machine[Mark] <> BLANK() ), Machine[Date and Time], , asc, Dense)
+ Machine[Mark]

 

 

Add measure called "Total Worktime"

 

Total Worktime = 
CALCULATE(
    SUM(Machine[WorkTime]), 
    Filter(
        ALLSELECTED(Machine), 
        Machine[Rank] = MAX(Machine[Rank]) && 
        Machine[Date and Time] <= MAX(Machine[Date and Time])
    )
)

Drop table visual on canvas and add following fields:

 

- Date and Time

- Work Time

- Total Work Time

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

 Hey @parry2k

 

Thank you for your answer.

 

The problem is, as i wrote before... i don't have any tables and no ablility to create ones, create colums etc. All tabels functions are inactive 😕

 

I get my dataset this way: IotHub -> Azure -> StreamAnalitysc -> (through PowerBI outputs) -> PowerBI

 

In PBI Dektop i chose Get Data -> Online Service -> Power BI Service

 

@parry2k... i was wondering. Maybe i could do this with summing resetBit value and summing WorkTime from 0 for different values in Sum(Mark) column. Table explain what i mean, but as i said i dont have tables, just metrics:

Date and TimeWorkTimeMarkSum(Mark)
2017-12-12 16:00120  
2017-12-12 16:00122 0
2017-12-12 16:00 11
2017-12-12 16:00125 1
2017-12-12 16:00  1
2017-12-12 16:00111 1
2017-12-12 16:01123 1
2017-12-12 16:01112 1
2017-12-12 16:01123 1
2017-12-12 16:0114512
2017-12-12 16:01156 2
2017-12-12 16:01125 2
2017-12-12 16:02  2
2017-12-12 16:02123 2
2017-12-12 16:02121 2
2017-12-12 16:02113 2
2017-12-12 16:02  2
2017-12-12 16:03154 2

 

So, for Sum(Mark)=1 Sum of Work time = 594.
For Sum(Mark)=2 Sum of Work time = 792.

 

Can i do this somehow?

Or i can send Mark that is already summed like this:

Date and TimeWorkTimeMark
2017-12-12 16:001200
2017-12-12 16:001220
2017-12-12 16:001251
2017-12-12 16:001111
2017-12-12 16:011231
2017-12-12 16:011121
2017-12-12 16:011231
2017-12-12 16:011452
2017-12-12 16:011562
2017-12-12 16:011252
2017-12-12 16:021232
2017-12-12 16:021212
2017-12-12 16:021132
2017-12-12 16:031542

Which one would be better to do what i want?

2nd option looks great. Assuming Mark is grouping the data together, and it will be always new after a stop time.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Yea it worked, thanks parry2k so this is solved, but i have question about another thing which i had in same project.

I don't have ability to change input value frome sum to just showing the last value. For examle when i take Card from visialisation and put ther WorkTime value it will show me sum of every WorkTime values - i can't change it to last one.

 

So i tried to use this function:

LastWorkTime = CALCULATE(SUM('Machine'[WorkTime]);LASTNONBLANK('Machine'[Date and Time];1))

but when i did that it return me "null" value.

So i am now sending Mark2 value with each WorkTime sending which is increased by 1 with every send. The function looks like that now
LastWorkTime = CALCULATE(SUM('Machine'[WorkTime]);LASTNONBLANK('Machine'[Mark2];1))

and it works fine, but why the one with [Date and Time] doesn't??

It will be much easier for the future if the function with Date and Time would work properly.

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.