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
plawrence14
Regular Visitor

calculate by MTD just giving blank output

Hi,

 

I am very new to Power BI so please forgive me for any ignorance. I did search for a solution but the solutions I found did not seem to work for me. 

 

I have an Invoice table with lots of different columns on. One being 'invoice value' and one being 'dateCreated'.

I created my own Date table with Dates and offsets. Within is a column called 'dates' with every date from 2015 to 2030.

 

I linked the two tables by the 'dateCreated' and 'date' columns. I have tried this one-to-many, many-to-one, and many-to-many.

 

If i do

invValue = CALCULATE(sum(Invoice[InvoiceValue]))
I get the value of all invoice for all time so I know that works.
 
Now I would like to get last month's so I have tried writing different measures. The first:
invoiceValueMTD = SUMX(FILTER(Dates, Dates[MonthOffset]=-1),Invoice[Total Invoice Value])
and the second:
invoiceValueMTD = CALCULATE(SUM(Invoice[InvoiceValue]),DATESMTD(Dates[Date]))
 
Both give blank outputs on the card

 

Could anyone help please?

 

Thanks

 

Paul

1 ACCEPTED SOLUTION

Hi Everyone,

 

So i have got this working, But the way i did it feels wrong still result is result

 

So  i then added the following measures to the invoice table

 

CurrentDate = NOW()
CurrentDay = Day(NOW())
CurrentMonth = MONTH(NOW())
CurrentYear = YEAR(NOW())

 

then i added these colums to the invoice table

 

 

Month = MONTH(invoice[DateCreated])
MonthName = FORMAT(invoice[DateCreated],"mmm")
Quarter = QUARTER(invoice[DateCreated])
Year = YEAR(invoice[DateCreated])

DayOffset = CONVERT(invoice[DateCreated]-TODAY(),INTEGER)
Week Offset = ROUNDUP((invoice[DateCreated]-TODAY ())/7,0)
MonthOffset = (invoice[YearOffset]*12) + (invoice[Month] - Invoice[CurrentMonth])
YearOffset = invocie[Year] - invoice[CurrentYear]

 

Then i wrote my measure as

 

LastMonthTotalValue =
SUMX(
    FILTER('Invoice',Invoice[MonthOffset] = -1),
    Invoice[InvoiceValue]
)
 
This worked and gave me the correct data but it really feels clumbersome as i may want dates for another table and would rather use a central date table
 
Thanks
 
Paul

 

 

 

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@plawrence14 See if the techniques in this video help:

Also: To **bleep** With Time Intelligence - Microsoft Fabric Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

HI,

 

So I have created new date tables several time and had a couple of hours with chat GPT several different forulas keep giving teh same blank out put on the card visuals.

 

Any ideas would be appreciated

 

Thansk

 

Paul

HI Greg,

 

I think thats pointing me in the right direction, I shall make a new dates table and see where that goes

 

Thanks you I will update stommorow after i have played some more

 

Paul

Hi Everyone,

 

So i have got this working, But the way i did it feels wrong still result is result

 

So  i then added the following measures to the invoice table

 

CurrentDate = NOW()
CurrentDay = Day(NOW())
CurrentMonth = MONTH(NOW())
CurrentYear = YEAR(NOW())

 

then i added these colums to the invoice table

 

 

Month = MONTH(invoice[DateCreated])
MonthName = FORMAT(invoice[DateCreated],"mmm")
Quarter = QUARTER(invoice[DateCreated])
Year = YEAR(invoice[DateCreated])

DayOffset = CONVERT(invoice[DateCreated]-TODAY(),INTEGER)
Week Offset = ROUNDUP((invoice[DateCreated]-TODAY ())/7,0)
MonthOffset = (invoice[YearOffset]*12) + (invoice[Month] - Invoice[CurrentMonth])
YearOffset = invocie[Year] - invoice[CurrentYear]

 

Then i wrote my measure as

 

LastMonthTotalValue =
SUMX(
    FILTER('Invoice',Invoice[MonthOffset] = -1),
    Invoice[InvoiceValue]
)
 
This worked and gave me the correct data but it really feels clumbersome as i may want dates for another table and would rather use a central date table
 
Thanks
 
Paul

 

 

 

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