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

Forecast with power Bi

Good evening,


Hoping someone can help me figure this out. I've tried many different options but none of them was efficient.


I have a model with 2 tables, the human resource database with the hours, áreas, and types of consultant, and a calendar table.

 

I've done two measures with simple things. "Horas contratadas"

josegracaaxians_0-1717689290751.png

and 

josegracaaxians_1-1717689305257.png

 I have this table:

josegracaaxians_2-1717689454805.png

and what I wanted is like :

josegracaaxians_3-1717690169566.png

And I need to predict the rest of hours based on recent consumption (based on last 3/6 months)

 

1 ACCEPTED SOLUTION

HI @josegracaaxians,

Sure, I think these date range not existed in your fact table, right?
IF that is the case, I'd like to suggest you change the 'horas realizadas' expression to check if the current calendar date existed in your table.
Then you can find out the last date which has value as the output for the not existed date ranges.

horas realizadas =
VAR currDate =
    MAX ( 'Calendar'[Date] )
VAR _lastDate =
    MAXX ( ALLSELECTED ( Eventos ), [Date] )
VAR lastResult =
    CALCULATE (
        SUM ( Eventos[horas] ),
        FILTER ( ALLSELECTED ( Eventos ), [Date] = _lastDate )
    )
RETURN
    IF ( currDate >= _lastDate, lastResult, SUM ( Eventos[horas] ) )

Regards,

Xiaoxin Sheng

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

View solution in original post

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

HI @josegracaaxians,

I'm not so clear for expressions that use in the measure, can you please share the formula about 'Horas realizadas' ?

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.

Good morning, 

'Horas realizas is a simple sum of database :

josegracaaxians_0-1717748527860.png

Thank You for your attencion.

HI @josegracaaxians,

Sure, I think these date range not existed in your fact table, right?
IF that is the case, I'd like to suggest you change the 'horas realizadas' expression to check if the current calendar date existed in your table.
Then you can find out the last date which has value as the output for the not existed date ranges.

horas realizadas =
VAR currDate =
    MAX ( 'Calendar'[Date] )
VAR _lastDate =
    MAXX ( ALLSELECTED ( Eventos ), [Date] )
VAR lastResult =
    CALCULATE (
        SUM ( Eventos[horas] ),
        FILTER ( ALLSELECTED ( Eventos ), [Date] = _lastDate )
    )
RETURN
    IF ( currDate >= _lastDate, lastResult, SUM ( Eventos[horas] ) )

Regards,

Xiaoxin Sheng

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

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.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors