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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Rupsayar
New Member

MdxScript(Model) (38, 2) Error!

Hello,

 

I'm new to Power BI and a big shout out to the community!

I'm facing a peculiar problem. Let me explain in layman's terms (as I am one!):


I have created a P&L dashboard, the data exported from .xls to the same. I have a date field [End Date] and a [Revenue] field. I wanted to create a month-over-month (MoM%) change in [Revenue] with respect to [End Date]. So I created a Bar-and-Line combo chart, with [Revenue] data as 'bars' and MoM% change as 'line'. I used the 'Quick Measures' feature and created a field [Revenue MoM%]. And I got what I wanted, see 'Revenue (MoM%)' figure below:

PnL Error 1.PNG

Now, when I used the date slicer to fine tune on (any) timeframe, I got the error:

 

 

 

PnL Error 2.PNG

 PnL Error 3.PNG

Can anyone please help me resolve this?

2 ACCEPTED SOLUTIONS
v-yuezhe-msft
Employee
Employee

@Rupsayar,

Regarding to the issue why the above error throws when using date slicer  to filter the chart, please review this similar thread.

In your scenario, please change the DAX of the measure by removing the IF statement. There is an example fo your reference.

SalesAmount MoM%  = 
IF(
	ISFILTERED('Calendar'[DateKey]),
	ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
	VAR __PREV_MONTH =
		CALCULATE(
			SUM('Sales'[SalesAmount]),
			DATEADD('Calendar'[DateKey].[Date], -1, MONTH)
		)
	RETURN
		DIVIDE(SUM('Sales'[SalesAmount]) - __PREV_MONTH, __PREV_MONTH)
)


Change to:

SalesAmount MoM% = 

	VAR __PREV_MONTH =
		CALCULATE(
			SUM('Sales'[SalesAmount]),
			DATEADD('Calendar'[DateKey].[Date], -1, MONTH)
		)
	RETURN
		DIVIDE(SUM('Sales'[SalesAmount]) - __PREV_MONTH, __PREV_MONTH)



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@Rupsayar,

Glad to hear  the issue is solved, you can accept my reply as answer to close this thread.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Rupsayar
New Member

Thanks. Solved.

@Rupsayar,

Glad to hear  the issue is solved, you can accept my reply as answer to close this thread.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yuezhe-msft
Employee
Employee

@Rupsayar,

Regarding to the issue why the above error throws when using date slicer  to filter the chart, please review this similar thread.

In your scenario, please change the DAX of the measure by removing the IF statement. There is an example fo your reference.

SalesAmount MoM%  = 
IF(
	ISFILTERED('Calendar'[DateKey]),
	ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
	VAR __PREV_MONTH =
		CALCULATE(
			SUM('Sales'[SalesAmount]),
			DATEADD('Calendar'[DateKey].[Date], -1, MONTH)
		)
	RETURN
		DIVIDE(SUM('Sales'[SalesAmount]) - __PREV_MONTH, __PREV_MONTH)
)


Change to:

SalesAmount MoM% = 

	VAR __PREV_MONTH =
		CALCULATE(
			SUM('Sales'[SalesAmount]),
			DATEADD('Calendar'[DateKey].[Date], -1, MONTH)
		)
	RETURN
		DIVIDE(SUM('Sales'[SalesAmount]) - __PREV_MONTH, __PREV_MONTH)



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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