cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Frequent Visitor

## Daily Increase problem

I have multiple meters that I can see and show how much they have gone up by as below, to get the daily value I need to subtract the max of the day for the min for the day;

 Factory Location Area Line _TIMESTAMP _VALUE Fact1 MANUF Area1 Sub1 09/02/2021 15:59 1585783 Fact1 MANUF Area1 Sub1 09/02/2021 16:15 1585783 Fact1 MANUF Area1 Sub1 09/02/2021 16:31 1585784 Fact1 MANUF Area1 Sub1 09/02/2021 16:47 1585784 Fact1 MANUF Area1 Sub1 09/02/2021 17:03 1585785 Fact1 MANUF Area1 Sub1 09/02/2021 17:19 1585785 Fact1 MANUF Area1 Sub1 09/02/2021 17:35 1585785 Fact1 MANUF Area1 Sub1 09/02/2021 17:51 1585786 Fact1 MANUF Area1 Sub1 09/02/2021 18:07 1585786

I have created a calculation, and this works at the line detail, but when I want to show on a visual the Area / Location / Factory level it breaks and will not show the correct calculation.

``````Active Energy Delived = (
CALCULATE( SUM(Sheet1[_VALUE]) , FILTER ( Sheet1 , Sheet1[_TIMESTAMP] = MAX( ( Sheet1[_TIMESTAMP] ) )))
-
(CALCULATE( SUM(Sheet1[_VALUE]) , FILTER ( Sheet1 , Sheet1[_TIMESTAMP] = MIN( ( Sheet1[_TIMESTAMP] ) ))))
)``````

Do I need to modify my DAX or do I need to create a summarize table to get this view?

Thanks

1 ACCEPTED SOLUTION
Super User

Hi, @MrGriff

Please check the below picture and the sample pbix file's link down below.

If I may suggest, I prefer to have date column and time column separately.  Because in case there is time-based analysis is needed, it is more efficient.

Even if you do not split it for this time, you can still try to write something similar to the below.

Active Energy Delivered =
VAR currentdate =
MAX ( 'Calendar'[Date] )
VAR currentarea =
MAX ( Data[Area] )
VAR currentlocation =
MAX ( Data[Location] )
VAR currentfactory =
MAX ( Data[Factory] )
VAR startlevel =
CALCULATE (
SUM ( Data[_VALUE] ),
FILTER (
ALLSELECTED ( Data ),
Data[Time] = MIN ( Data[Time] )
&& Data[Date] = currentdate
&& Data[Area] = currentarea
&& Data[Location] = currentlocation
&& Data[Factory] = currentfactory
)
)
VAR endlevel =
CALCULATE (
SUM ( Data[_VALUE] ),
FILTER (
ALLSELECTED ( Data ),
Data[Time] = MAX ( Data[Time] )
&& Data[Date] = currentdate
&& Data[Area] = currentarea
&& Data[Location] = currentlocation
&& Data[Factory] = currentfactory
)
)
RETURN
endlevel - startlevel

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

4 REPLIES 4
Super User

maybe you can try to create a date column

``DATE = INT('Table'[_TIMESTAMP])``

then create a measure

``````Measure =
var _MIN=CALCULATE(MIN('Table'[_TIMESTAMP]),ALLEXCEPT('Table','Table'[Area],'Table'[Factory],'Table'[Line],'Table'[Location],'Table'[DATE]))
VAR _MAX=CALCULATE(MAX('Table'[_TIMESTAMP]),ALLEXCEPT('Table','Table'[Area],'Table'[Factory],'Table'[Line],'Table'[Location],'Table'[DATE]))
RETURN MAXX(FILTER('Table','Table'[_TIMESTAMP]=_MAX),'Table'[_VALUE])-MAXX(FILTER('Table','Table'[_TIMESTAMP]=_MIN),'Table'[_VALUE])``````

Proud to be a Super User!

Super User

Hi, @MrGriff

Please check the below picture and the sample pbix file's link down below.

If I may suggest, I prefer to have date column and time column separately.  Because in case there is time-based analysis is needed, it is more efficient.

Even if you do not split it for this time, you can still try to write something similar to the below.

Active Energy Delivered =
VAR currentdate =
MAX ( 'Calendar'[Date] )
VAR currentarea =
MAX ( Data[Area] )
VAR currentlocation =
MAX ( Data[Location] )
VAR currentfactory =
MAX ( Data[Factory] )
VAR startlevel =
CALCULATE (
SUM ( Data[_VALUE] ),
FILTER (
ALLSELECTED ( Data ),
Data[Time] = MIN ( Data[Time] )
&& Data[Date] = currentdate
&& Data[Area] = currentarea
&& Data[Location] = currentlocation
&& Data[Factory] = currentfactory
)
)
VAR endlevel =
CALCULATE (
SUM ( Data[_VALUE] ),
FILTER (
ALLSELECTED ( Data ),
Data[Time] = MAX ( Data[Time] )
&& Data[Date] = currentdate
&& Data[Area] = currentarea
&& Data[Location] = currentlocation
&& Data[Factory] = currentfactory
)
)
RETURN
endlevel - startlevel

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Frequent Visitor

Hi @Jihwan_Kim

Thanks for the help, I have tried to do the same as above but I get the below when I implement your solution,

I have attached the PBIX here for you to have a look at what I have done;

https://1drv.ms/u/s!AjC_xz2zXa0Ug-tYBlkfyUtQ5aYEzQ?e=fB6vuQ

If you can help that would be great.

Thanks

Super User

Hi, @MrGriff

Can you tell me which date / which area / which location / which factory information do you want to show in card visualization? Without selecting the criteria, I do not know what to show.

Thank you.

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors