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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
MichaelaMul
Helper III
Helper III

Make a measure a calculated column in order to make it a slicer

Hi,

 

I am trying to change my measure into a calculated column so that I can make it a slicer, to filter if the product is "NEW". There's multiple Geographies and Times in the Data, so I would want it to be New within that specific geography and time.

 

The measure is below:

New $ = IF(values('Data'[Dollar Sales])=values('Data'[Dollar Sales Change vs YA]),"NEW","--")

Calculated column I made, but it doesn't work

NEW $$ = 
IF(
HASONEVALUE
('Data'[Product]) && Data[New $]= "NEW","NEW","--")

I also tried the following calculated column and this also didn't work

NEW $$ = 
var DollarSales = 
CALCULATE(
        SUM([Dollar Sales]),
        FILTER('Data','Data'[Geography] = EARLIER('Data'[Geography]) && 'Data'[Time] = EARLIER('Data'[Time]))
    )
var DollarSalesChg = 
CALCULATE(
        SUM([Dollar Sales Change vs YA]),
        FILTER('Data','Data'[Geography] = EARLIER('Data'[Geography]) && 'Data'[Time] = EARLIER('Data'[Time]))
    )
var _result =
IF( HASONEVALUE('Data'[Product]) &&
    DollarSales = DollarSalesChg,
    "NEW",
    "NOT NEW"
)
RETURN
_result

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MichaelaMul ,

 

Here I have a test by your sample and I think I find the solution.

According to your statement, I think your issue is that there are a measure and a calculated column in your report, when you select the slicer, the measure works but calculated column won't.

As far as I know, calculated column couldn't be dynamic like measure, it is calculated by the row filter and will show static result in your data model.
If you want to show dynamic results based on filters, a measure should be a better way.

For reference: Calculated Columns and Measures in DAX - SQLBI

 

Best Regards,
Rico Zhou

 

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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @MichaelaMul ,

 

According to your code, I have some questions on your measure and calculated column.

1. You use VALUES() in your measure, I think it will return error due to VALUES() will return a table, table = table is incorrect.

2. I think the logic of [New $$] (the second one) should be correct. So I think this should be caused by your data model.

Here I suggest you to show more details or share a sample file with us and show us a screenshot with the result you want. This will make it easier for us to find the solution.

 

Best Regards,
Rico Zhou

 

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

 

 

Hi! Thank you for your reply. The measure I'm not using in the table, so I don't think its related.

Below is a table with the measure and the calculated column together. As you can see the measure is working but the calculated column is not.

MichaelaMul_0-1726752844213.png

 

here's some sample data:

GeographyTimeProductBrandCustom Hood SegmentVolume SalesVolume Sales Change vs YAUnit SalesUnit Sales Change vs YADollar SalesDollar Sales Change vs YAACV Weighted DistributionACV Weighted Distribution Year AgoVolume per $MM per ItemVolume per $MM per Item Change vs YAUnits per $MM per ItemUnits per $MM per Item Change vs YADollars per $MM per ItemDollars per $MM per Item Year AgoPrice per UnitPrice per Unit Year AgoWeighted Average Base Price Per Unit Year AgoWeighted Average Base Price Per UnitSegmentCustom Hood Size ValueVolume Share of SegmentCustom Hood Category ValueCustom Hood Sub Category ValueCustom Hood Type ValueVolume Sales % Change vs YAUnit Sales % Change vs YADollar Sales % Change vs YAVolume Sales Year AgoUnit Sales Year AgoDollar Sales Year Ago
Store ALatest 13 WeeksStrawberry MilkFlavored FarmMILK1,658106,63041$40,320$1,32624.4928721.522410.109935-0.013190.439741-0.052772.6742182.914695$6.085.9180366.3229566.400841Oat VAM32 OZ 1 CT0.174746VALUE - ADDED MILKSPECIALTY MILKN/A0.62%0.62%3.40%1647.25658938993.94
Store ALatest 4 WeeksStrawberry MilkFlavored FarmMILK488361,951145$12,262$71421.0613618.944730.036071-0.001080.144284-0.004310.9068360.950126$6.296.3941426.4531556.413196Oat VAM32 OZ 1 CT0.16745VALUE - ADDED MILKSPECIALTY MILKN/A8.03%8.03%6.19%451.5180611547.82
Store BLatest 13 WeeksStrawberry MilkFlavored FarmMILK24,244-2,87496,975-11,497$590,450($65,396)17.9565917.360050.158188-0.036670.632751-0.146673.8526144.712556$6.096.0462326.2490216.301643Oat VAM32 OZ 1 CT0.227253VALUE - ADDED MILKSPECIALTY MILKN/A-10.60%-10.60%-9.97%27117.99108471.9655846.6
Store BLatest 4 WeeksStrawberry MilkFlavored FarmMILK7,753-86331,012-3,451$183,381($18,197)16.6893216.232320.053404-0.010850.213616-0.04341.2631741.503352$5.915.8491396.2027236.284832Oat VAM32 OZ 1 CT0.235299VALUE - ADDED MILKSPECIALTY MILKN/A-10.01%-10.01%-9.03%8615.70934462.84201577.9
Store CLatest 13 WeeksStrawberry MilkFlavored FarmMILK24,382-2,75497,527-11,018$593,730($62,529)11.7824111.393440.105555-0.022770.422222-0.091072.5622543.102661$6.096.0459666.2486186.299692Oat VAM32 OZ 1 CT0.167258VALUE - ADDED MILKSPECIALTY MILKN/A-10.15%-10.15%-9.53%27136.24108544.9656259
Store CLatest 4 WeeksStrawberry MilkFlavored FarmMILK7,804-81631,215-3,265$184,590($17,084)10.9203410.655050.034942-0.007330.139769-0.029320.8264490.988909$5.915.8490416.202456.282883Oat VAM32 OZ 1 CT0.171896VALUE - ADDED MILKSPECIALTY MILKN/A-9.47%-9.47%-8.47%8619.95934479.84201674
Store ALatest 13 WeeksCoffee MilkCowMILK1,0181,0184,0704,070$11,658$11,65812.50493 0.1321820.1321820.528730.528731.51446 $2.86  2.987117Oat VAM32 OZ 1 CT0.107272VALUE - ADDED MILKSPECIALTY MILKN/A      
Store ALatest 4 WeeksCoffee MilkCowMILK3003001,1991,199$3,326$3,32612.71846 0.0367090.0367090.1468360.1468360.407258 $2.77  2.985893Oat VAM32 OZ 1 CT0.102908VALUE - ADDED MILKSPECIALTY MILKN/A      
Store BLatest 13 WeeksCoffee MilkCowMILK1,0511,0514,2024,202$12,040$12,0401.153139 0.1067480.1067480.4269920.4269921.223338 $2.87  2.988447Oat VAM32 OZ 1 CT0.009848VALUE - ADDED MILKSPECIALTY MILKN/A      
Store BLatest 4 WeeksCoffee MilkCowMILK3093091,2371,237$3,430$3,4301.15691 0.0307340.0307340.1229350.1229350.340802 $2.77  2.98591Oat VAM32 OZ 1 CT0.009387VALUE - ADDED MILKSPECIALTY MILKN/A      
Store CLatest 13 WeeksCoffee MilkCowMILK1,0511,0514,2024,202$12,040$12,0400.749555 0.0693880.0693880.277550.277550.795185 $2.87  2.988447Oat VAM32 OZ 1 CT0.007207VALUE - ADDED MILKSPECIALTY MILKN/A      
Store CLatest 4 WeeksCoffee MilkCowMILK3093091,2371,237$3,430$3,4300.749286 0.0199050.0199050.079620.079620.220724 $2.77  2.98591Oat VAM32 OZ 1 CT0.006813VALUE - ADDED MILKSPECIALTY MILKN/A      
Store BLatest 13 WeeksChocolate MilkCowMILK3,8623,8628,3798,379$41,782$41,7825.836493 0.0775230.0775230.1681990.1681990.838758 $4.99  5.555639Oat VAM59 OZ 1 CT0.036199VALUE - ADDED MILKSPECIALTY MILKN/A      
Store BLatest 4 WeeksChocolate MilkCowMILK427427927927$5,153$5,1532.794423 0.0175720.0175720.0381260.0381260.212008 $5.56  5.641672Oat VAM59 OZ 1 CT0.012964VALUE - ADDED MILKSPECIALTY MILKN/A      
Store CLatest 13 WeeksChocolate MilkCowMILK4,5464,5469,8639,863$47,773$47,7733.894377 0.0513920.0513920.1115030.1115030.553968 $4.84  5.327271Oat VAM59 OZ 1 CT0.031184VALUE - ADDED MILKSPECIALTY MILKN/A      
Store CLatest 4 WeeksChocolate MilkCowMILK4974971,0791,079$5,763$5,7631.868921 0.0115580.0115580.0250770.0250770.138852 $5.34  5.413106Oat VAM59 OZ 1 CT0.010952VALUE - ADDED MILKSPECIALTY MILKN/A      
Store BLatest 13 WeeksVanilla MilkMilk FarmMILK16-27,99644-74,657$239########0.01987812.96310.09622-0.173340.256587-0.462231.409413.103848$5.494.3180034.9843745.84483Oat VAM48 OZ 1 CT0.000153VALUE - ADDED MILKSPECIALTY MILKN/A-99.94%-99.94%-99.93%28012.5274700.06322555.1
Store BLatest 4 WeeksVanilla MilkMilk FarmMILK4-10,20812-27,221$68########0.00539312.474950.094023-0.005080.250728-0.013541.4516741.063277$5.794.0234044.9554785.789827Oat VAM48 OZ 1 CT0.000134VALUE - ADDED MILKSPECIALTY MILKN/A-99.96%-99.96%-99.94%10212.3227232.85109568.8
Store CLatest 13 WeeksVanilla MilkMilk FarmMILK20-37,88755-101,032$261########0.04422711.534490.069576-0.152990.185535-0.407960.9423382.522529$4.784.2315974.7243065.065225Oat VAM48 OZ 1 CT0.00014VALUE - ADDED MILKSPECIALTY MILKN/A-99.95%-99.95%-99.94%37907.52101086.7427758.3
Store CLatest 4 WeeksVanilla MilkMilk FarmMILK8-13,24321-35,315$81########0.01431911.025840.067899-0.011780.181063-0.031420.9662410.853736$3.924.0157744.7347233.920655Oat VAM48 OZ 1 CT0.000172VALUE - ADDED MILKSPECIALTY MILKN/A-99.94%-99.94%-99.94%13250.8235335.51141899.4
Store ALatest 13 WeeksOriginal MilkCowMILK4,122-1,8578,243-3,714$32,299($21,787)24.6798938.173650.2713020.0193370.5426040.0386732.1260282.279338$3.924.5231184.9478724.53571Oat VAM59 OZ 1 CT0.434537VALUE - ADDED MILKSPECIALTY MILKN/A-31.06%-31.06%-40.28%5978.85111957.754086.1
Store ALatest 4 WeeksOriginal MilkCowMILK1,7252623,450524$12,286($2,380)23.9359334.061530.112250.04530.22450.09060.7995030.671144$3.565.0122865.0486684.369323Oat VAM59 OZ 1 CT0.592212VALUE - ADDED MILKSPECIALTY MILKN/A17.91%17.91%-16.23%1463292614665.95
Store BLatest 13 WeeksOriginal MilkCowMILK144,277-155,496288,553-310,992################37.4416266.483980.451479-0.110970.902958-0.221933.9896044.968045$4.424.416474.9311144.810683Oat VAM59 OZ 1 CT1.352401VALUE - ADDED MILKSPECIALTY MILKN/A-51.87%-51.87%-51.85%299772.6599545.22647874
Store BLatest 4 WeeksOriginal MilkCowMILK41,772-44,46783,544-88,933$369,360########35.7184162.184330.134444-0.033440.268889-0.066891.1887891.499465$4.424.4656664.8690274.782189Oat VAM59 OZ 1 CT1.267771VALUE - ADDED MILKSPECIALTY MILKN/A-51.56%-51.56%-52.05%86238.79172477.6770227.3
Store CLatest 13 WeeksOriginal MilkCowMILK190,814-235,736381,627-471,471################27.3912551.923360.311361-0.210120.622722-0.420232.7619764.506101$4.404.2793424.6802654.754536Oat VAM59 OZ 1 CT1.308969VALUE - ADDED MILKSPECIALTY MILKN/A-55.27%-55.27%-54.02%426549.3853098.63650701
Store CLatest 4 WeeksOriginal MilkCowMILK55,407-69,666110,814-139,332$486,222########26.2095249.156130.093476-0.064120.186951-0.128230.8311911.376578$4.394.3189654.6305544.729149Oat VAM59 OZ 1 CT1.220476VALUE - ADDED MILKSPECIALTY MILKN/A-55.70%-55.70%-54.99%125072.9250145.71080371
Anonymous
Not applicable

Hi @MichaelaMul ,

 

Here I have a test by your sample and I think I find the solution.

According to your statement, I think your issue is that there are a measure and a calculated column in your report, when you select the slicer, the measure works but calculated column won't.

As far as I know, calculated column couldn't be dynamic like measure, it is calculated by the row filter and will show static result in your data model.
If you want to show dynamic results based on filters, a measure should be a better way.

For reference: Calculated Columns and Measures in DAX - SQLBI

 

Best Regards,
Rico Zhou

 

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

What I would like to do is create a slicer for whether or not a product is new. I can't use a measure as a slicer so I was trying to use a calculated column. Is there another way to do this?

dharmendars007
Super User
Super User

Hello @MichaelaMul , 

 

You can try the below code...and also Earlier and Hasonevalue it may not work as expected in calculated column when dealing with multiple columns.

 

NEWStatus =
VAR CurrentGeography = 'Data'[Geography]
VAR CurrentTime = 'Data'[Time]
VAR DollarSales = CALCULATE(
SUM('Data'[Dollar Sales]),
'Data'[Geography] = CurrentGeography,
'Data'[Time] = CurrentTime)
VAR DollarSalesPrevYear = CALCULATE(
SUM('Data'[Dollar Sales]),
'Data'[Geography] = CurrentGeography,
SAMEPERIODLASTYEAR('Data'[Time])
VAR SalesChange = DollarSales - DollarSalesPrevYear
RETURN
IF(
HASONEVALUE('Data'[Product]) && SalesChange > 0,"NEW","NOT NEW")

 

If you find this helpful , please mark it as solution and Your Kudos/Likes are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.