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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JimmyKhan2022
Frequent Visitor

Rewrite of Measure for Customer Count Required ?

Problem Statement

 

I am trying to get a ROLLING 12 month count of new customers in a line graph, but currently sometime it appears, and sometimes it fails with the below error or it takes a long time to appear.

 

Figure 1 – Memory Error

JimmyKhan2022_0-1679493545411.png

 

 

The page has a Financial Year and Financial Month Selected by the user.  There are 4 measures that are used to do the following:

 

Measure1_Revenue – Current Selected Monthly Revenue figure for calculation.

 

Measure2_Revenue_Prev_23 – Getting the Monthly Revenue Total for the prior 23 months.

 

Measure3_New Cust by Month – Get a count of customers where they have revenue for the current month selected and no revenue for the previous 23 months. They are a new customer.

 

Customer_Count_Ignore_Date_filters – The measure that is used in the graph to override the DATE filters on the top of the page and display the customer count for each month in the last 12 months.

 

 

The ask for this please is there a way to rewrite the Customer_Count_Ignore_Date_filters so this works please ?

Customer_Count_Ignore_Date_filters =

 

var selectedDate = MAX('Time'[Date])

var PreviousDates = DATESINPERIOD('Previous Date'[Date], selectedDate, -13, MONTH)

 

var result =  CALCULATE(  

 [Measure3_New Cust by Month]

,REMOVEFILTERS('Time'),

KEEPFILTERS(PreviousDates),

USERELATIONSHIP('Time'[Date],'Previous Date'[Date]) )  

RETURN

result

 

 

PBIX attached . Power BI

1 REPLY 1
lbendlin
Super User
Super User

No wonder this is slow/expensive. You have measures inside measures inside measures inside measures etc. Flatten this out. Use DAX Studio to examine the query plan and to refactor your code.

 

(BTW it renders on a PC with 32 GB of RAM)

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors