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
sammy02hk
Helper I
Helper I

Modifying DAX Code for retrieve full data

Hi there,

Below is the sum of Sales with 

LLM last last month, LM Last Month, TM This Month

Hope my result like:

sammy02hk_0-1676963046586.png

1st approach:

sammy02hk_0-1676961703391.png

Right now i can retrieve the result by selecting Billing Month. 

Without selecting Billing Month Error Message: A table of multiple values was supplied where a single value was expected

 

2nd approach:

Its not working since i have to use month as one of my parameter.

sammy02hk_0-1676963234321.png

 

How can I modify the code so that I can have a full picture without selecting Month.

 

Thank you for your help.

 

Sammy Chu

1 ACCEPTED SOLUTION
RichardOfSydney
Regular Visitor

mSale:=SUM(Sales[sale])

mSalesLM:=CALCULATE([mSale],PARALLELPERIOD('Calendar'[Date],-1,MONTH))

mSalesLLM:=CALCULATE([mSale],PARALLELPERIOD('Calendar'[Date],-2,MONTH))

RichardOfSydney_0-1676968160499.png

 

View solution in original post

6 REPLIES 6
RichardOfSydney
Regular Visitor

mSale:=SUM(Sales[sale])

mSalesLM:=CALCULATE([mSale],PARALLELPERIOD('Calendar'[Date],-1,MONTH))

mSalesLLM:=CALCULATE([mSale],PARALLELPERIOD('Calendar'[Date],-2,MONTH))

RichardOfSydney_0-1676968160499.png

 

Hi @RichardOfSydney ,

Thank you for your help.
But the LLM get the same result with This month.

sammy02hk_0-1676968900203.png

Cheers,

Sammy Chu

Dont use the var, they are 3 distinct measures.

RichardOfSydney_0-1676969149529.png

 

@RichardOfSydney 
Its work, when the sum put back. Thank you very much

sammy02hk_0-1676969073069.png

 

FreemanZ
Super User
Super User

hi @sammy02hk 

try like:

...
var LLMonth - DATEADD(MAX(Monthly_All[Billing_Month]),-2,MONTH)
...

Hi @FreemanZ 
Thank you for your help. I got the below error message.

sammy02hk_0-1676962894907.png

 

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.