cancel
Showing results for 
Search instead for 
Did you mean: 

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

Reply
Udit
New Member

Convert Calculated Column to measure

Consider the Following Power BI dashboard Model :


We have 3 tables

Table 1 : EM table
There are no duplicate rows in the table.


Table 2 : Norm Table
MaxUpdateFlag1 - is calculated columns

In the table, the below columns are used as filters to obtain the unique value for R_Val.
Cuc ,Date, DMA_Date,P_P,P_T,GT1, R_D

Also, the below columns are used as filters to obtain the unique value for S_Val and T_Val.
Cuc, Date, DMA_Date


Code for MaxUpdateFlag1

MaxUpdateFlag1 =
Var CurrentRow = 'Norm'[DMA_DATE]
VAR MaxUpdate =
CALCULATE(
MAX('Norm'[DMA_Date]),
ALLEXCEPT( 'Norm',
'Norm'[EMID],
'Norm'[DATE],
'Norm'[P_P],
'Norm'[CUC],
'Norm'[GT1],
'Norm'[P_T],
'Norm'[R_T],
'Norm'[R_D]
)
)
RETURN IF(CurrentRow = MaxUpdate, 1, 0)

The third Table is Dates, it is a calculated table with the following code :
Dates = CALENDAR (MIN('Norm Table' [DATE]), MAX('Norm Table' [DATE]))


This is how tables interact together on the relationship model,

EM Table is joined to Norm Table using Column EMID
The relationship is One(EM Table) to Many (Norm Table) in cardinality
Cross-filtering is set to both.

Norm Table is joined to the Dates Table using the Date column
The relationship is One(Dates) to Many (Norm Table) in cardinality, and cross-filtering is set to one-directional.


The matrix visual has the following information in order:
Rows :
E_ID from EM table
EName from EM table
R_D from Norm table
S_Val from Norm table
T_Val from Norm table

Columns :
P_P from Norm Table
R_T from Norm Table

Values :
R_Val from Norm table

In the Filter on this visual section of the matrix

The MaxUpdateFlag1 column from the Norm Table has been added, value is set to 1.

The Idea for setting up the column value to 1 is to display the latest R_Val, S_Val, and T_Val based on the latest information-based  DMA_Date Column.
I am looking to change MaxUpdateFlag1 to a measure.
I have a large dataset and a calculated column is not feasible.
Sample PBIX

1 REPLY 1
lbendlin
Super User
Super User

 

I am looking to change MaxUpdateFlag1 to a measure.

 

Why? Can it be impacted by user interaction with the report?

 

your existing calculated column can be refactored to 

MUF = if([DMA_Date]=maxx(Norm,[DMA_Date]),1,0)

if you want to use a measure, rewrite this to 

MUF = if(SELECTEDVALUE(Norm[DMA_Date])=maxx(Norm,[DMA_Date]),1,0)

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

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

Power BI Fabric Summit Carousel

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