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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Jackie003
Frequent Visitor

Different measure for different account number

Hello I have in my data model: Calendar table, FCT Parameters table, Forecast Costs table. In Forecast Costs table I have data from Jan 2024 till Oct 2024. I want to show data also for missing months. 

I made my dax formula to check if it's work and it' ok:

Forecast=
VAR maxdate =
    MAX ( 'Calendar'[Date])
RETURN
    CALCULATE (
        LASTNONBLANKVALUE ( 'Calendar'[Month], SUM ('Forecast Costs'[Quantity])*1.05 ),
        ALL ( 'Calendar' ),
        'Calendar'[Date] <= maxdate
    )
I can see future months with last available value for OCT (In Nov and Dec I can see OCT Values). I want to rebuild my formula for specific account numbers. In FCT Parameters table I have "Rule" column ("Average", "Prev Month" - thats my text values). I want to display future months (NOV and DEC), but when my account number has "Average" rule I want to see in NOV and DEC average costs from Jan to Oct. For "Prev Month" rule i want to see previous month value. Does Anyone can help with that? 
2 REPLIES 2
Jackie003
Frequent Visitor

Unfortunately, it does not work

bhanu_gautam
Super User
Super User

@Jackie003 , Try using below mentioned measure

 

Forecast =
VAR maxdate = MAX('Calendar'[Date])
VAR currentRule = SELECTEDVALUE('FCT Parameters'[Rule])
VAR result =
SWITCH(
currentRule,
"Average",
CALCULATE(
AVERAGEX(
DATESBETWEEN('Calendar'[Date], DATE(2024, 1, 1), DATE(2024, 10, 31)),
'Forecast Costs'[Quantity]
),
ALL('Calendar'),
'Calendar'[Date] <= maxdate
),
"Prev Month",
CALCULATE(
LASTNONBLANKVALUE('Calendar'[Month], SUM('Forecast Costs'[Quantity])),
ALL('Calendar'),
'Calendar'[Date] <= maxdate
),
// Default case if no rule matches
CALCULATE(
LASTNONBLANKVALUE('Calendar'[Month], SUM('Forecast Costs'[Quantity]) * 1.05),
ALL('Calendar'),
'Calendar'[Date] <= maxdate
)
)
RETURN
result




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.