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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Greger1337
Frequent Visitor

Filter X-axis

I have as measure calculating sales of last 18 months:

Volume_18M = CALCULATE([Fsg volym];FILTER(Datum;Datum[Date]>DATE(YEAR(TODAY());MONTH(TODAY())-18;DAY(TODAY()))))

In a bar chart I want to display this per month.

To show when there is Zero sales I have selescted to show values without data but this gives me an X-axis like below.

 

 

How do I filter my datetable to only show values between Today and 18 months back on X-axis?

1 ACCEPTED SOLUTION

Unfortunatley this filters the categories on my X-axis if there is no data for the Year-Month.

 

I managed to get it working with this measure:

Volym_18M = CALCULATE(
       IF([Fsg volym]=0 
            && (LASTDATE(Datum[Date]) > 
                 DATE(YEAR(TODAY());MONTH(TODAY())-18;DAY(TODAY())) 
                 && LASTDATE(Datum[Date]) < TODAY()) ;0;[Fsg volym]);
       FILTER(Datum;Datum[Date]>DATE(YEAR(TODAY());MONTH(TODAY())-18;DAY(TODAY()))))

View solution in original post

2 REPLIES 2
kaushikd
Resolver II
Resolver II

You can use the page level filter or visual level filter to get the last 18 month Volume, no need of writing dax for that. Try this and let me know if that fix your problem.

 

 

Capture.JPG

For more details you can follow this link

https://docs.microsoft.com/en-us/power-bi/desktop-slicer-filter-date-range#using-the-relative-date-r...

Unfortunatley this filters the categories on my X-axis if there is no data for the Year-Month.

 

I managed to get it working with this measure:

Volym_18M = CALCULATE(
       IF([Fsg volym]=0 
            && (LASTDATE(Datum[Date]) > 
                 DATE(YEAR(TODAY());MONTH(TODAY())-18;DAY(TODAY())) 
                 && LASTDATE(Datum[Date]) < TODAY()) ;0;[Fsg volym]);
       FILTER(Datum;Datum[Date]>DATE(YEAR(TODAY());MONTH(TODAY())-18;DAY(TODAY()))))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors