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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Ritaf
Responsive Resident
Responsive Resident

changing context to last month dax

Hi, 
I have a table with cars transactions by month like below:

carIDMonthly_KMmonth of transaction

1

100001/01/2020
1150001/02/2020
1130001/01/2021
2140001/01/2020
280001/01/2022

I am trying to bin cars by average km yearly, and when I visualize it in yearly granularity I want to count the cars of last month with the transaction. For example, in 2020 it is December and in 2021 it is April.
the counting with classifications working great and shows the right numbers on monthly granularity, but I have a problem, to filter for "last transaction's" month when it is a yearly granularity.  My formula is:

kmGroup =
SUMX('KM bins table''', COUNTROWS(FILTER('cars',[kmAverage]>'KM bins table'''[Min] && [kmAverage]<'KM bins table''[max])))
How can I fix it to show me the last month on yearly granularity (I have a date table)
Thank you, Rita
1 ACCEPTED SOLUTION
Ritaf
Responsive Resident
Responsive Resident

I solved it by myself with:

Fitered KM_group =
CALCULATE([kmGroup],LASTNONBLANK('Calendar[date]',[cars quantity])

View solution in original post

1 REPLY 1
Ritaf
Responsive Resident
Responsive Resident

I solved it by myself with:

Fitered KM_group =
CALCULATE([kmGroup],LASTNONBLANK('Calendar[date]',[cars quantity])

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors