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
Bokazoit
Responsive Resident
Responsive Resident

Can this measure become dynamic?

This measure gives me the difference between two estimates, and was generated by power bi desktop quick measures.

 

For now I have two estimates but soon I have 3 and more and I want this measure to always look at the two filtered estimates and calculate the difference.

 

Estimat difference =
VAR __BASELINE_VALUE =
    CALCULATE(
        [Estimat værdi],
        'FactEstimat'[Estimat version] IN { "Estimat ved Q1 2021" }
    )
VAR __MEASURE_VALUE = [Estimat værdi]
RETURN
    __MEASURE_VALUE - __BASELINE_VALUE
 
The measure uses this version of the Estimate, but I want it to be dynamic according to the two different estimate-versions I choose.
 
Skærmbillede 2021-02-18 081338.jpg
 
Any help is greatly appreciated 🙂
1 ACCEPTED SOLUTION
Bokazoit
Responsive Resident
Responsive Resident

I am clearly a n00b, I did everything wrong turned off my brain. I added the Estimate version column to the matrix and that was ofcourse not usable. removing that and creating two measures with the min/max function and then subtract, did the trick. Tx for the help

Estimat1 = 

Var MaxDate = MAX ( 'FactEstimat'[Estimat version] )

RETURN

CALCULATE (
    SUM ( FactEstimat[#Estimat] ),
    FILTER (
        FactEstimat,
        (
            FactEstimat[Estimat version] = MaxDate
        )
    ),
    ALL ( DimDato )
)

View solution in original post

4 REPLIES 4
Bokazoit
Responsive Resident
Responsive Resident

I am clearly a n00b, I did everything wrong turned off my brain. I added the Estimate version column to the matrix and that was ofcourse not usable. removing that and creating two measures with the min/max function and then subtract, did the trick. Tx for the help

Estimat1 = 

Var MaxDate = MAX ( 'FactEstimat'[Estimat version] )

RETURN

CALCULATE (
    SUM ( FactEstimat[#Estimat] ),
    FILTER (
        FactEstimat,
        (
            FactEstimat[Estimat version] = MaxDate
        )
    ),
    ALL ( DimDato )
)
az38
Community Champion
Community Champion

hi @Bokazoit 

it depends but you can try this technique

Estimat difference =
var __prevVersion = CALCULATE ( MIN ( 'FactEstimat'[Estimat version] ) )
VAR __BASELINE_VALUE =
    CALCULATE(
        [Estimat værdi],
        'FactEstimat'[Estimat version] = __prevVersion
    )
VAR __MEASURE_VALUE = [Estimat værdi]
RETURN
    __MEASURE_VALUE - __BASELINE_VALUE

or

Estimat difference =
var __curVersion
var __prevVersion = CALCULATE ( MAX ( 'FactEstimat'[Estimat version] ), 'FactEstimat'[Estimat version] < __curVersion )
VAR __BASELINE_VALUE =
    CALCULATE(
        [Estimat værdi],
        'FactEstimat'[Estimat version] = __prevVersion
    )
VAR __MEASURE_VALUE = [Estimat værdi]
RETURN
    __MEASURE_VALUE - __BASELINE_VALUE

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Bokazoit
Responsive Resident
Responsive Resident

Number 1 did not do the trick

 

And something is wrong with the second suggestion

 

Bokazoit_0-1613635477598.png

 

Hi, @Bokazoit 

Try formula as below:

Estimat difference = 
VAR _FIRST_VERSION =
    MAX ( FactEstimat[Estimat version] )
VAR _SECOND_VERSION =
    MIN ( FactEstimat[Estimat version] )
VAR __FIRST_VALUE =
    CALCULATE ( [Estimat værdi], 'FactEstimat'[Estimat version] = _FIRST_VERSION )
VAR __SECOND_VALUE =
    CALCULATE ( [Estimat værdi], 'FactEstimat'[Estimat version] = _SECOND_VERSION )
RETURN
    __FIRST_VALUE - __SECOND_VALUE

Check my sample file for more details.

70.png

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.