cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Latest reading formula

Hi, 

Can someone help me with a calculated column and a dax formula, both would have been nice. I want only the latest reading of every ID if the the tempratur is 5 or above give me true, if not give me false. 

I am only intrested in the latest reading for that paticular day. 

Capture.PNG


Here are a sample from the data. 

thanx in advance



7 REPLIES 7
Highlighted
Super User IV
Super User IV

Re: Latest reading formula

Hi @Anonymous 

Please try the below Measure.

 

Measure = 
VAR __tbl = ADDCOLUMNS( 
    VALUES( 'YorTable'[Id] ),
    "mDate", CALCULATE( 
        MAX('YorTable'[Timestamp] ), 
        ALLEXCEPT( 'YorTable', 'YorTable'[Id] )
    )
)
RETURN 
CALCULATE(
    COUNTROWS( 'YorTable' ),
    KEEPFILTERS( 
        TREATAS( __tbl, 'YorTable'[Id], 'YorTable'[Timestamp] ) 
    )
) >= 5

 

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Anonymous
Not applicable

Re: Latest reading formula

Hi @Mariusz

Thanx for your help but, 

I am only getting false, not getting true or false? Can you please check and modify this. Something is clearly missing. 


Capture.PNG

Highlighted
Super User IV
Super User IV

Re: Latest reading formula

Hi @Anonymous 

The expression I posted previously was a Measure if you need a column, please use the below

 

Spoiler
Column = 
VAR mDate = CALCULATE(
    MAX(YourTable[Timestamp]),
    ALLEXCEPT(YourTable, YourTable[Id])
)
RETURN YourTable[Timestamp] = mDate && YourTable[Temoratur] >= 5

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.  

Highlighted
Super User IV
Super User IV

Re: Latest reading formula

Hi @Anonymous 

 

Samall adjustment to a Measure

Measure = 
VAR __tbl = ADDCOLUMNS( 
    VALUES( 'YourTable'[Id] ),
    "mDate", CALCULATE( 
        MAX('YourTable'[Timestamp] ), 
        ALLEXCEPT( YourTable, YourTable[Id] )
    )
)
RETURN 
CALCULATE(
    MAX( 'YourTable'[Temoratur] ),
    KEEPFILTERS( 
        TREATAS( __tbl, 'YourTable'[Id], 'YourTable'[Timestamp] ) 
    )
) >= 5

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Anonymous
Not applicable

Re: Latest reading formula

Hi again @Mariusz 

Thanx alot for all help this looks better  I will test this out very soon. I am drillingthrough from one page to the next. So when I am on the next page I want this value to be visualise this in a kpi card in my report, if the value is 5 or above give me green light, if 5 or below give me red. How can I visualise this in a best possible way?

Can I use the adcanve card, or any help would be very nice. I am open for any solution and visualtiation. Giving you a screenshot with a example white circle. 


Capture.PNG

Highlighted
Super User IV
Super User IV

Re: Latest reading formula

Hi @Anonymous 

Are you looking for measure that you can use for conditonal formating or the visual?

Thanks 
Mariusz

Highlighted
Anonymous
Not applicable

Re: Latest reading formula

@Mariusz 

you have given me a formula for the tempratur and latest reading. But I want to visualse diplay this as green or red light. 

As a kpi trafficlight but not in a table, just a card. If the tempratur is 5 or above give me green light, if the value is 5 or less give med red. Have you understood? Maybe you have some suggestion of how to visualise this in a best way


Thanx alot in advance

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Power BI Desktop August 2020 Update

Power BI Desktop August 2020 Update

We have great updates this month! Click the link for the video with more info.

Top Solution Authors
Top Kudoed Authors