Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate with 2 filters provides blank as a result

Hi, 

I want to get the latest value for a specific time and date, but when I apply two filters to my formula, it results in BLANK.  

I appreciate any tips on that:) . 

This is my calculation: 

Sensor Value latest = CALCULATE (
    fact_sensordata[Sensor Value],
    FILTER (
       ALL ( 'fact_sensordata'[date_id] ),
      'fact_sensordata'[date_id]
            = MAX ( 'fact_sensordata'[date_id] )
   ),
    FILTER (
    ALL ( 'fact_sensordata'[time_id] ),
    'fact_sensordata'[time_id]
   = MAX ( 'fact_sensordata'[time_id] )
   )
)
 
This is calculation for Sensor Value: 
Sensor Value = AVERAGE(fact_sensordata[sensorValue])

 

This is my fact table: 

 

sensor_idtime_iddate_idSensor value
1492511100
149261532
1512748877
3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Sensor Value latest =
VAR T1 =
    SUMMARIZE (
        fact_sensordata,
        'fact_sensordata'[date_id],
        'fact_sensordata'[time_id],
        "@SensorValue", [Sensor Value]
    )
VAR T2 =
    TOPN (
        1,
        T1,
        'fact_sensordata'[date_id], DESC,
        'fact_sensordata'[time_id], DESC
    )
RETURN
    MAXX ( T2, [@SensorValue] )
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your full dataset looks like, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1662988678090.png

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
goncalogeraldes
Super User
Super User

Hello there @Anonymous ! Not sure if this is what you want but try this:

 

Sensor Value latest =
CALCULATE (
    AVERAGE( fact_sensordata[Sensor Value] ),
    ALL ( 'fact_sensordata'[date_id], 'fact_sensordata'[time_id] ),
    'fact_sensordata'[date_id] = MAX ( 'fact_sensordata'[date_id] )
        && 'fact_sensordata'[time_id] = MAX ( 'fact_sensordata'[time_id] )
)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.