cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Frequent Visitor

## Measure resulting on wrong value within the context

There are two rolling measures I'm trying to achieve but both of them are NOT working as I think they should.

There are no blank/empty/null values (pbix attached in the end) and yet it still doesn't work.

I'm trying to calculate a "rolling distinc count" based on shifts and my subtotals are resulting on different values than they should.

My Measure 1 is basically this:

On shift 1 (Turno 1, between 0h to 7h ), I'm calculating the DISTINCTCOUNT of each f_MovMad[Placa do Cavalo] line within the shift.
On shift 2 (Turno 2, between 8h to 15h ), I'm calculating the DISTINCTCOUNT of each f_MovMad[Placa do Cavalo] line within shift 2 AND shift 1 (between 0 am to 15 pm)
On shift 3 (Turno 3, 16h to 23h), I'm calculating the DISTINCTCOUNT of the whole day (Turno 1, 2 and 3).

Heres the DAX:

Measure 1 =

SWITCH(

The exact same error is happening with me with the SUM running total on Measure 2:

Measure 2 =
CALCULATE (
FILTER (
)
)

For example, the "CORRECT 2" column it's the way it should SUM correctly on "MEASURE 1", so the expected result should be this:

The values within "Turno 3" should always be the same as the subtotal, since they both calculate within the same context, whole day.
I'm stuck with this formula for a couple of days now, I would be extremely grateful if someone could help me troubleshoot this!

1 ACCEPTED SOLUTION
Resolver IV

``````Contagem Placas AC =
SWITCH(
)

VAR _Max = MAX( 'f_MovMad'[Turno] )
RETURN
CALCULATE(
REMOVEFILTERS(),
VALUES( 'd_Calendário'[Data] )
)``````

And the selected column in your chart

Result:

2 REPLIES 2
Resolver IV

``````Contagem Placas AC =
SWITCH(
)

VAR _Max = MAX( 'f_MovMad'[Turno] )
RETURN
CALCULATE(
REMOVEFILTERS(),
VALUES( 'd_Calendário'[Data] )
)``````

And the selected column in your chart

Result:

Frequent Visitor

You're a lifesaver! Worked perfectly.
As I could see I was using the wrong column for the context ("d_CadTransportadoras"[Tipo de Transporte]) but I didn't urderstand the difference between ALL and ALLSELECTED for the "Contagem Placas AC" measure, can you explain the logic difference between them?

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors