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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Bokazoit
Post Patron
Post Patron

Need help with measure

This measure is created using a detached Date dimension - as can be seen from this data model:

 

Bokazoit_0-1650615821076.png

 

Doing that makes it possible to calculate the correct distinct count, using this DAX:

 

Antal verserende sager = 

VAR MinDato = MIN('FilterDato (Verserende sager)'[DatoFilterKey])

RETURN

CALCULATE(
    DISTINCTCOUNT(FactArvesager[ArvesagsKey]),
    FactArvesager[Forventet afsluttet Dato] >= MinDato && 
    FactArvesager[Bostarts Dato] < MinDato &&
    (FactArvesager[Realiseretarv Dato] = BLANK() || FactArvesager[Realiseretarv Dato] >= MinDato),
    USERELATIONSHIP(FactArvesager[Forventet afsluttet Dato],DimDato[DatoKey])
)

 

The VAR MinDato gives the  minimum date in my date filter:

 

Bokazoit_1-1650616000181.png

 

But the datamodel is not that userfriendly, and I would like to use the date from my Date dimension (DimDato) instead of the detached date dimension. 

 

The problem is that when I use the Date dimension it gives me the wrong result. If I use this measure:

 

Antal verserende sager test = 

VAR MinDato = MIN(DimDato[DatoKey])

RETURN

CALCULATE(
    DISTINCTCOUNT(FactArvesager[ArvesagsKey]),
    FactArvesager[Forventet afsluttet Dato] >= MinDato && 
    FactArvesager[Bostarts Dato] < MinDato &&
    (FactArvesager[Realiseretarv Dato] = BLANK() || FactArvesager[Realiseretarv Dato] >= MinDato),
    USERELATIONSHIP(FactArvesager[Forventet afsluttet Dato],DimDato[DatoKey])
)

 

Were I use the Date Dimension (DimDato) instead of the detached date dimension, I get 4 records more:

 

Bokazoit_2-1650616301957.png

The minimum date is 1. april 2022:

 

Bokazoit_1-1650616000181.png

The green row is correct since it is before the minimum date and the filter in the measure works, but the 4 red rows is not correct as can be seen - since all 4 records is after 1. april 2022.

To me it looks as if the variable MinDato (= minimum date from the datefilter) is calcualted differently than I would expect.

 

So therefor I need to have a detached date dimension. Can You tell me how to get the date correct?

Any help is really appreciated 🙂

9 REPLIES 9
v-rongtiep-msft
Community Support
Community Support

Hi @Bokazoit ,

How about modifying this measure?

Antal verserende sager test = 

VAR MinDato = MINX(ALL(DimDato),DimDato[DatoKey])

RETURN

CALCULATE(
    DISTINCTCOUNT(FactArvesager[ArvesagsKey]),
    FactArvesager[Forventet afsluttet Dato] >= MinDato && 
    FactArvesager[Bostarts Dato] < MinDato &&
    (FactArvesager[Realiseretarv Dato] = BLANK() || FactArvesager[Realiseretarv Dato] >= MinDato),
    USERELATIONSHIP(FactArvesager[Forventet afsluttet Dato],DimDato[DatoKey])
)

 

If it does not help, how about creating relationships like the Filterdato?

 

If I have misundstood your meaning, please provide your desired output and your  pbix file without privacy information.

How to Get Your Question Answered Quickly 

 

Best Regards

Community Support Team _ Polly

 

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

Does not help at al 😞

Hi @Bokazoit ,

If I have misundstood your meaning, please provide your desired output and your  pbix file without privacy information.

How to Get Your Question Answered Quickly 

 

Best Regards

Community Support Team _ Polly

 

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

@v-rongtiep-msft See the pbix file I have added now. Hope for a solution. If I hardcode the date in the measure it works also, but that is not a possible way - ofcourse

Here is a sample file:

 

https://drive.google.com/file/d/1yjp20i4tZP0GAnSbSe-06f4TtkQowIrh/view?usp=sharing 

There is two sheets, and the results in each sheet is correct, but for the result in the sheet 'Forecast' to be correct, I need to create a new date dimension as described above. I would like to use just the Primary date dimension.

 

Hope this gives You what You need.

 

Thx in advance 🙂

@Bokazoit 

As discussed here

Payeras_BI_0-1652806826007.png

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Bokazoit
Post Patron
Post Patron

I think You should post this in Your own thread 🙂

lbendlin
Super User
Super User

It's not clear what the actual issue is.  Why would a disconnected data table that feeds your slicer be "not user friendly" ?

Because the user have to use one dimension for filtering, and another for date types

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 Carousel June 2024

Check out the June 2024 Power BI update to learn about new features.

2
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.