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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
PBIViz_2024
Advocate I
Advocate I

Direct Query-Calculate function-No values

Hi All,

 

I have PBI Dashbaord developed initially using import and I am trying to do the same using Direct query.howver below function works well in import but no values resulting in direct query.

Total Tonnage-Latest =
Var Latest_time=CALCULATE(max(Table1[datetime_val]),all(Table1))
Var _output=CALCULATE(sum(Table1[value]),Table1[datetime_val]=Latest_time,ALLSELECTED(Dimensiontable1[category]))
Return _output
 
Please let me know if any idea on this.
 
Regards,
 
2 REPLIES 2
Anonymous
Not applicable

Hi @PBIViz_2024 

Pleasre try the following Dax:

Total Tonnage-Latest =
VAR Latest_time = CALCULATE(MAXX(ALL(Table1), Table1[datetime_val]))
VAR _output =
CALCULATE(
SUM(Table1[value]),
FILTER(
Table1,
Table1[datetime_val] = Latest_time
),
ALLSELECTED(Dimensiontable1[category])
)
RETURN _output


 

 

 

 

 

Best Regards,

Jayleny

 

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

Fowmy
Super User
Super User

@PBIViz_2024 

You code looks okay, check if any other filters affecting the calcultion on the report. Try to run a Evaluate Table1 in DAX Query View

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors