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 August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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