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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
paris
Helper V
Helper V

Relationship problem

Hi all,

 

I have forecast and actual data in diffenet format and want to combine in report format. 

I can not change forecast from monthly basis to daily basis. Could you please help me to set up relationship?

 

Relationship.JPG

 

All the best,

LoveParis

1 ACCEPTED SOLUTION

Hi Zoe,

 

Thank you for sending me the demo file.

 

1) Is there any reason actual is under calender?

2) I use slicer to select by country or city. 

3) However..   I set up relationships (same as yours) but it seems not working. I got total value (sum of paris, london, tokyo) for each day. Is there any possible reason causing this problem? 

 

All the best,

LoveParis

 

View solution in original post

5 REPLIES 5
dax
Community Support
Community Support

Hi paris,

You need three tables, Actual, Foreaast and calendar, then you could create a column in actual table like below

Column = SWITCH(Actual[city],"Tokyo","Japan", "Japan","Japan", "London","UK", "Paris", "France")

create the relationship like below

210.PNG

Then create measures like below

actual =
CALCULATE (
    SUM ( Actual[productions] ),
    FILTER ( ALL ( Actual ), Actual[date] = MIN ( 'calendar'[Date] ) )
)
forcast =
CALCULATE (
    SUM ( Forcast[production] ),
    FILTER (
        ALLEXCEPT ( Forcast, Forcast[Country] ),
        MONTH ( Forcast[date] ) = MONTH ( MIN ( 'calendar'[Date] ) )
    )
)

Then you could create table like below

211.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Zoe,

 

Thank you very much for your reply!Smiley Happy

 

1) I do not need to build relationship between calender and forecast/actual?

2) People keep adding new cities. Instead of using switch function, can I creat a new table country/city and build relationship with forecast/actual? 

 

All the best,

LoveParis

dax
Community Support
Community Support

Hi paris, 

Yes, you don't need to create relationship between calendar and actual,. And if you want to use another country table, you could create relationship like below

212.PNG

You could refer to my pbix file for more details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Zoe,

 

Thank you for sending me the demo file.

 

1) Is there any reason actual is under calender?

2) I use slicer to select by country or city. 

3) However..   I set up relationships (same as yours) but it seems not working. I got total value (sum of paris, london, tokyo) for each day. Is there any possible reason causing this problem? 

 

All the best,

LoveParis

 

Zoe,

 

Thank you very much for your help. I was able to solve my problem (it was caused because I did not set up many to many relation ship for both fact tables)

 

Thank you again!

 

All the best

LoveParis

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.