Forum Discussion
Calculated Column Index that Restarts from 1 Based on Values in Another Column
- 1 year ago
Hi,
Thank you for your message, and it is possible.
Please let me know if you have date column and time column separately in the table, or date&time column (combined) in the table.
If you have the combined column in the table, it is pretty much similar to the above solution. Please try to write the same DAX formula and check whether it works.
However, if you have separate column in the table, I tried to create a new sample like below, and please check the below picture and the attached pbix file.
Or, it would be great if you could share your sample pbix file's link, and then I can try to look into it.
Thank you.
IndexCC = VAR _condition = ADDCOLUMNS ( NPS, "@condition", IF ( NPS[NetPromoterSystem] = "Promoter", 0, 1 ) ) VAR _group = ADDCOLUMNS ( _condition, "@group", SUMX ( FILTER ( _condition, NPS[CreatedDate]+NPS[CreatedTime] <= EARLIER ( NPS[CreatedDate])+EARLIER(NPS[CreatedTime]) ) , [@condition] ) ) VAR _index = ADDCOLUMNS ( _group, "@index", SUMX ( FILTER ( _group, NPS[CreatedDate]+NPS[CreatedTime] <= EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime]) && [@group] = EARLIER ( [@group] ) ), 1 ) ) RETURN MAXX ( FILTER ( _index, NPS[CreatedDate]+NPS[CreatedTime] = EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime]) && NPS[SurveyName] = EARLIER ( NPS[SurveyName] ) && NPS[NetPromoterSystem] = EARLIER ( NPS[NetPromoterSystem] ) ), [@index] )
Hi Jihwan_Kim
Thank you for your response. You understood correctly, and your output is perfect. However, I have "Other" values that show up on the same day as "Promoter". Is it possible to incorporate time as well?
Hi,
Thank you for your message, and it is possible.
Please let me know if you have date column and time column separately in the table, or date&time column (combined) in the table.
If you have the combined column in the table, it is pretty much similar to the above solution. Please try to write the same DAX formula and check whether it works.
However, if you have separate column in the table, I tried to create a new sample like below, and please check the below picture and the attached pbix file.
Or, it would be great if you could share your sample pbix file's link, and then I can try to look into it.
Thank you.
IndexCC =
VAR _condition =
ADDCOLUMNS (
NPS,
"@condition", IF ( NPS[NetPromoterSystem] = "Promoter", 0, 1 )
)
VAR _group =
ADDCOLUMNS (
_condition,
"@group",
SUMX (
FILTER ( _condition, NPS[CreatedDate]+NPS[CreatedTime] <= EARLIER ( NPS[CreatedDate])+EARLIER(NPS[CreatedTime]) ) ,
[@condition]
)
)
VAR _index =
ADDCOLUMNS (
_group,
"@index",
SUMX (
FILTER (
_group,
NPS[CreatedDate]+NPS[CreatedTime] <= EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime])
&& [@group] = EARLIER ( [@group] )
),
1
)
)
RETURN
MAXX (
FILTER (
_index,
NPS[CreatedDate]+NPS[CreatedTime] = EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime])
&& NPS[SurveyName] = EARLIER ( NPS[SurveyName] )
&& NPS[NetPromoterSystem] = EARLIER ( NPS[NetPromoterSystem] )
),
[@index]
)