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

How to get previous month data with ID to ID relationship

Hello everyone,

 

I have two tables :

- DIM_Period which is a date table, containing [ID_Period] (integer), [Period] (text) and [Date] (date)

- FACT_Table wich is the tbale where my values are stored, containing [ID_Period] (integer) and [Value] (integer)

 

I am trying to display in a visual the sum of value for current month and for previous month for a selected period, like this :

AriBnK_0-1705912286133.png

But in order to reduce report size, I mapped the DIM_Period table to my FACT_Table with IDs of integer type (because integer type is less size consuming than date type).

So my relationship looks like this :

AriBnK_1-1705912569243.png

And here is my problem : I can't find a way to use PREVIOUSMONTH or DATEADD correctly with that case.
I created a mesaure like this :

PreviousMonth = CALCULATE(SUM(FACT_Table[Value]), PREVIOUSMONTH(DIM_Period[Date]))
 
But the result of the measure was blank in the table :
AriBnK_2-1705913678873.png

Does someone can help me with that problem ?

 

I would like to continue mapping the DIM & FACT tables with ID relationship

 

Thank you

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

It is best practice to use calendar "offsets"

Learn about "offsets" here Click here for Offset tutorial video 

 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

View solution in original post

1 REPLY 1
speedramps
Super User
Super User

It is best practice to use calendar "offsets"

Learn about "offsets" here Click here for Offset tutorial video 

 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.