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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ImSctm
Frequent Visitor

How to use a "measured column" to filter a virtual table

Hello,


Does someone know how to filter a table from a created column that comes from a new variable? I'll show the measure:

--------------------------------------------------------------------------------------

VAR Dif_Hours =
Hores_Mes_Actual - Hores_Mes_Anterior
//I have a number diference = [hours this month - hours previous month] as a starting point //


VAR Numero_Feines_Incrementen =
    COUNTAX(
        CALCULATETABLE(
            ADDCOLUMNS(
                SUMMARIZE('Productivitat DIA','Productivitat DIA'[NAME]
                ),
                "Dif_Hours123",Dif_Hours
            ),
        Dif_Hours123>0),
    'Productivitat DIA'[NAME]
    )
//What I want is to use the variable Dif_Hours as a filter to COUNTAX and only count rows number of Productivitat DIA'[NAME] that have Dif_Hours > 0.  //


Of course, DAX doesn't accept the new column "Dif_Hours123" as a table name or a correct function. But I can't find a suitable alternative.

Much appreciated if you can help...


Update: 
I've got something closer by applying countax after virtual table. Still result not satisfactory as it shows total of rows without filter:
Total is 11 and by filtering it should be 5.

----------------------------------------------------------
VAR
Diferencia_Hores =
Hores_Mes_Actual - Hores_Mes_Anterior

VAR Taula_Dif_Hores =
    CALCULATETABLE(
        ADDCOLUMNS(
            SUMMARIZE('Productivitat DIA','Productivitat DIA'[NAME]
            ),
            "Dif_Hores",Diferencia_Hores
        )
    )

RETURN
COUNTAX(
    FILTER(Taula_Dif_Hores,[Dif_Hores]>0),[Dif_Hores])


1.JPG

 

0 REPLIES 0

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.