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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Bokazoit
Continued Contributor
Continued Contributor

Measure to use different values depending on dates

I have this data model:

 

Bokazoit_0-1760603091871.png


One measure for the table FactFinans: SUM('FactFinans (HF)'[#Bogførtbeløb])*-1

And another measure for FactEstimat: 
Sum('FactEstimat (HF)'[#Estimat])

Depending on the 'estimate version' I calculate a date (a quarter). If the choosen 'estimate version' is 'Q4 2025' I calculate a date to split what measure to use:

VAR EstimatQuarter= MID(MAX('FactEstimat (HF)'[Estimat version]), 2, 1) * 1
VAR EstimatYear = MID(MAX('FactEstimat (HF)'[Estimat version]), 4, 4)

VAR EndMonth= SWITCH(
    TRUE(),
    EstimatQuarter= 2, 3,
    EstimatQuarter= 3, 6,
    EstimatQuarter= 4, 9
)

VAR LastDayInMonth= DAY(EOMONTH(DATE(EstimatYear, EndMonth, 1), 0))
VAR ActualFinansDate= DATE(EstimatYear, EndMonth, LastDayInMonth)


From here I can't make it work. I would like the measure to use this:

SUM('FactFinans (HF)'[#Bogførtbeløb])*-1

 

when the financial dates in FactFinans is before ActualFinansDate else use:

Sum('FactEstimat (HF)'[#Estimat])

 

from FactEstimat

1 ACCEPTED SOLUTION
Kedar_Pande
Super User
Super User

Combined Amount =
VAR EstimatQuarter = MID(MAX('FactEstimat (HF)'[Estimat version]), 2, 1) * 1
VAR EstimatYear = MID(MAX('FactEstimat (HF)'[Estimat version]), 4, 4)
VAR EndMonth = SWITCH(TRUE(), EstimatQuarter = 2, 3, EstimatQuarter = 3, 6, EstimatQuarter = 4, 9)
VAR ActualFinansDate = EOMONTH(DATE(EstimatYear, EndMonth, 1), 0)
RETURN
CALCULATE(
SUM('FactFinans (HF)'[#Bogførtbeløb]) * -1,
'FactFinans (HF)'[Financial Date] <= ActualFinansDate
) +
CALCULATE(
SUM('FactEstimat (HF)'[#Estimat]),
'FactEstimat (HF)'[Financial Date] > ActualFinansDate
)

View solution in original post

5 REPLIES 5
v-veshwara-msft
Community Support
Community Support

Hi @Bokazoit ,
Just checking in to see if you had a chance to go through the response shared by @Kedar_Pande .

Let us know if you need any additional clarification or have further queries.

V-yubandi-msft
Community Support
Community Support

Hi @Bokazoit ,

I wanted to check if you had the opportunity to review the information provided by @Kedar_Pande . Please feel free to contact us if you have any further questions. 
 

Thank you and continue using Microsoft Fabric Community Forum.

Kedar_Pande
Super User
Super User

Combined Amount =
VAR EstimatQuarter = MID(MAX('FactEstimat (HF)'[Estimat version]), 2, 1) * 1
VAR EstimatYear = MID(MAX('FactEstimat (HF)'[Estimat version]), 4, 4)
VAR EndMonth = SWITCH(TRUE(), EstimatQuarter = 2, 3, EstimatQuarter = 3, 6, EstimatQuarter = 4, 9)
VAR ActualFinansDate = EOMONTH(DATE(EstimatYear, EndMonth, 1), 0)
RETURN
CALCULATE(
SUM('FactFinans (HF)'[#Bogførtbeløb]) * -1,
'FactFinans (HF)'[Financial Date] <= ActualFinansDate
) +
CALCULATE(
SUM('FactEstimat (HF)'[#Estimat]),
'FactEstimat (HF)'[Financial Date] > ActualFinansDate
)
bhanu_gautam
Super User
Super User

@Bokazoit Try using Calculate the ActualFinansDate

dax
VAR EstimatQuarter = MID(MAX('FactEstimat (HF)'[Estimat version]), 2, 1) * 1
VAR EstimatYear = MID(MAX('FactEstimat (HF)'[Estimat version]), 4, 4)
VAR EndMonth = SWITCH(
TRUE(),
EstimatQuarter = 2, 3,
EstimatQuarter = 3, 6,
EstimatQuarter = 4, 9
)
VAR LastDayInMonth = DAY(EOMONTH(DATE(EstimatYear, EndMonth, 1), 0))
VAR ActualFinansDate = DATE(EstimatYear, EndMonth, LastDayInMonth)

 

 

You want to sum FactFinans up to ActualFinansDate, and FactEstimat after that. You can use CALCULATE with FILTER to achieve this:

dax
Combined Measure =
VAR EstimatQuarter = MID(MAX('FactEstimat (HF)'[Estimat version]), 2, 1) * 1
VAR EstimatYear = MID(MAX('FactEstimat (HF)'[Estimat version]), 4, 4)
VAR EndMonth = SWITCH(
TRUE(),
EstimatQuarter = 2, 3,
EstimatQuarter = 3, 6,
EstimatQuarter = 4, 9
)
VAR LastDayInMonth = DAY(EOMONTH(DATE(EstimatYear, EndMonth, 1), 0))
VAR ActualFinansDate = DATE(EstimatYear, EndMonth, LastDayInMonth)
VAR FinansSum =
CALCULATE(
SUM('FactFinans (HF)'[#Bogførtbeløb]) * -1,
FILTER(
ALL('FactFinans (HF)'),
'FactFinans (HF)'[Dato] <= ActualFinansDate
)
)
VAR EstimatSum =
CALCULATE(
SUM('FactEstimat (HF)'[#Estimat]),
FILTER(
ALL('FactEstimat (HF)'),
'FactEstimat (HF)'[Dato] > ActualFinansDate
)
)
RETURN
FinansSum + EstimatSum




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

Proud to be a Super User!




LinkedIn






That looks AI generated?

I asked CoPilot and it returned that exact answer...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.