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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Top Solution Authors