cancel
Showing results for
Did you mean:

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

Post Patron

## Using a measure in a calculated column

Hi,

I have this calc col -> Punctuality = IF (OTIF[ShiftInTime]<OTIF[TimeFrom]-1/24*.25,"Early",

IF (OTIF[ShiftInTime]>OTIF[TimeFrom]+1/24*.25,"Late","On Time"

& IF (OTIF[ShiftInTime]>OTIF[TimeFrom]+1/24*1,"Perfect")))

I have this measure -> targetperc OT = LASTNONBLANK('OT%'[OT%],0.25)

I substitute the *.25 in th calc col with * targetperc OT to give me ->

Punctuality = IF (OTIF[ShiftInTime]<OTIF[TimeFrom]-1/24*[targetperc OT],"Early",

IF (OTIF[ShiftInTime]>OTIF[TimeFrom]+1/24*[targetperc OT],"Late","On Time"

& IF (OTIF[ShiftInTime]>OTIF[TimeFrom]+1/24*1,"Perfect")))

I have applied the values in OT% table to a slicer. However, when I select values in the slicer, nothing changes. Below is the table my measure is using.

What am I missing here?

10 REPLIES 10
Microsoft

@android1

Two things.

1. The targetperc OT is using the OTP% table, if it is using OT%, please change it.
`targetperc OT = LASTNONBLANK('OTP%'[OTP%],0.25)`
2. Not a calculated column Punctuality, use the expression in filters. For example as below. You can modify other measures where the Punctuality is involved accordingly. By this approach, the measure values vary according to the Slicer.
```Early =
COUNTROWS (
FILTER (
OTIF,
IF (
OTIF[ShiftInTime]
< OTIF[TimeFrom]
- 1 / 24
* [targetperc OT],
"Early",
IF (
OTIF[ShiftInTime]
> OTIF[TimeFrom]
+ 1 / 24
* [targetperc OT],
"Late",
"On Time"
& IF ( OTIF[ShiftInTime] > OTIF[TimeFrom] + 1 / 24 * 1, "Perfect" )
)
)
= "Early"
)
)```

Community Champion

Use of Parameters would be more appropriate solution in your case.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Post Patron

Parameters? Can you tell me how I can do this?

Community Champion

Can you please provide me a snapshot your dataset and I would be more than happy to provide you exact solution.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Post Patron

Here's my file. I had a go at adding a parameter and applying the values in my OT% table to it. Parameter name is OTP%.

https://www.dropbox.com/s/f9c12ioi82vh0zh/OTIF%20Extra%20Columns%20IF%20Slicer%20Final%20Last.pbix?d...

Community Champion

Hi Android1,

Firstly you have to create parameter ( list of values) based on your IF% Table.

This can be done in powerquery mode. Pass on all the list of the values of IF% Table.

create a new custom column,

Pass on your formula you created before and replace the value of 0.25 with Parameter name.

This will let you choose the value later on dynamically and you can select the value of your choice.

Hope this will clarify your problem. I was unable to create this for you because of connection settings.

Parameter table creationPassing onto the Parameters to your custom column

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Community Champion

You have to slightly change the formula for custom column as PowerQuery works on IF logic but have to add else statment too.

Let me know if you get stuck further.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Community Champion

Hi

You can not use measure in calculated column. you need to come up with some other logic.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Post Patron

Ah, ok. Thank you.

New Member

Try changing the column data format to "general".

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