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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SilvioLunaPBI
Frequent Visitor

Calculate count into calculaltetable

I have this code in dax, I need to be able to execute the code that is marked as "<-- ERROR", using the table variable.

var tb = CALCULATETABLE(
    SELECTCOLUMNS(RawData
    ,"service",RawData[Service]
    ,"period",RawData[StartOfPeriod_]
    ,"volume",RawData[Contact Volume]
    ,"position",RawData[Position]
    ))

var tb2 = CALCULATETABLE(
    SELECTCOLUMNS(tb
    ,"service",[service]
    ,"period",[period]
    ,"volume",[volume]
    ,"position",RANKX(FILTER(
        tb,
        [service] = EARLIER([service]) && 
        [period] = EARLIER([period])),[position],,ASC,Dense)
    ,"vendors",CALCULATE(COUNT([service]),ALLEXCEPT(tb,tb[StartOfPeriod_],tb[Service])) <-- ERROR
))

 

3 REPLIES 3
SilvioLunaPBI
Frequent Visitor

Any help?

amitchandak
Super User
Super User

@SilvioLunaPBI , Try like

 

addcolumns(summarize(tb
,"service",[service]
,"period",[period]
,"volume",[volume])
,"position",RANKX(FILTER(
tb,
[service] = EARLIER([service]) &&
[period] = EARLIER([period])),[position],,ASC,Dense)
,"vendors",CALCULATE(COUNT(tb[service]),ALLEXCEPT(tb,tb[StartOfPeriod_],tb[Service]))
)

 

 

Can you share a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I need to do it all in the measure not in calculated columns, I need to use dynamic filter all in measure

this is an example of file: https://drive.google.com/file/d/1e-PTQHjC-fFvhGMQiYNpNFW_67gBBZe8/view?usp=sharing


Tks

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.