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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
KenMann
Regular Visitor

Is is necessary for Date table to Mark as date for calculation ?

Hi guys,

 

May I know, is it necessary to mark a date table as Date, before using it for some calculation, for example to use it in SAMEPERIODLASTYER or PREVIOUSYEAR or DATEADD(date, -1, year) ?

 

Since I tried all those 3 DAX with my measure but all return wrongly, mostly blank.

 

I have FactTable named FactInternetSales and it has column SalesAmount. The measure I created are:

Sales amount = SUM(FactInternetSales[SalesAmount])

Sales amount LY = CALCULATE([Sales amount], SAMEPERIODLASTYEAR(Dates[Date])) or

Sales amount LY = CALCULATE([Sales amount], PREVIOUSYEAR(Dates[Date])) or

Sales amount LY = CALCULATE([Sales amount], DATEADD(Dates[Date], -1, year))

 

While the relationship is set between FactInternetSales[OrderDateKey] to Dates[DateKey]

 

Is it not working because I didn't mark the Dates table as Date ? 

 

Thanks,

 

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @KenMann ,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi Xiaoxin,

I would love to, but may I know how to change the storage mode to "Import" ?

I guess this is the way if we want to share the pbix, right ?

Currently it is on Mixed mode :

KenMann_0-1702308311746.png

 

I total won't mind about the data since it is on AdventureWorks and I'm on learning basis in Fabric.

A further explanation, the data set is from OneLakeHub, and all the tables is on Direct Query Mode ->

KenMann_1-1702308531173.png

 

Btw, I currently did change my Date dimension to "Mark as date table", but the DAX calculation is still not working. As in previous message, I'm creating my 2 measures like this :

1. Sales amount = SUM(FactInternetSales[SalesAmount])

2. Sales amount LY = CALCULATE([Sales amount], SAMEPERIODLASTYEAR(Dates[Date])) or

    Sales amount LY = CALCULATE([Sales amount], PREVIOUSYEAR(Dates[Date])) or

    Sales amount LY = CALCULATE([Sales amount], DATEADD(Dates[Date], -1, year))

 

Thanks

 

 

 

 

 

 

Greg_Deckler
Super User
Super User

@KenMann Maybe, but those functions are terrible. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Also:



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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