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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
renanvg7
New Member

DAX Query needs optimiziation

Hello all!

 

I'm making an Azure Table Cube access by DAX query in import mode from a telemetry level from several clients tanks.

 

This is a simple table, but very heavy (thousands of clients, sometimes 15 minutes based information, and I can't ensure that all the timestamps will be equal). I only need a simple table in which has the last level from the day for each client.

 

So, 4 columns are available in this cube: LevelDate, LevelDateTime, DPLevel(%) and DeliveryPointId

 

LevelDate | LevelDateTime | DPLevel(%) | DeliveryPointId

4/11/22  | 4/11/22 23:00 | 56 | 4466 |

4/11/22  | 4/11/22 23:30 | 55 | 4466 |

5/11/22  | 5/11/22 00:15 | 54 | 4466 |

5/11/22  | 5/11/22 00:30 | 53 | 4466 |

4/11/22  | 4/11/22 23:00 | 78 | 4467 |

5/11/22  | 5/11/22 00:00 | 77 | 4467 |

5/11/22  | 5/11/22 00:15 | 76 | 4467 |

 

I want to generate something like this, in order to improve performance (1 value for each day for each delivery point):

LevelDate | Last Level (%) | DeliveryPointId

4/11/22  | 55 | 4466 |

5/11/22  | 53 | 4466 |

4/11/22  | 78 | 4467 |

5/11/22  | 76 | 4467 |

 

I've tried to create a measure in the definitions that retrieves the value for the last datetime for the context, and creating a summarizecolumns for each date and delivery point id (that's the client id), and the logic worked (see below). However, it doesn't bring any value if I try filtering for periods longer than one week, and looks like the search for the last datetime stamp is very heavy in the lastnonblankvalue measure.

 

Given this structure, do you see any better way to generate this table?

 

DEFINE
MEASURE 'DPLevel'[LastLevel(%)] = LASTNONBLANKVALUE('DPLevel'[LevelDateTime],SELECTEDVALUE('DPLevel'[DPLevel(%)]))

 

Evaluate
SUMMARIZECOLUMNS (
'DPLevel'[LevelDate],
'DPLevel'[DeliveryPointId],
FILTER('DPLevel','DPLevel'[LevelDate]>=DATE(2022,1,1)),
"Last Level (%)", [LastLevel(%)]

)

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

Why not use Power Query to generate this table? DAX is not a mashup tool. It's an analytical tool. Power Query is for mashup.

amitchandak
Super User
Super User

@renanvg7 , refer to my way of getting the latest value, if that can help

Latest
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.