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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
uvil
Helper I
Helper I

Get the number of notes between two dates

Hey to all, 

 

It seems easy, but i'm having some troubles at the time, to do that measure, 

 

I want to create a measure that counts the dates that are between two other dates, I mean, I have two columns, and I want to know the number of notes that have been done between the dates of the other column, I made that measure, that, theorically, it have to work, but it doesn't, and well, I don't know how to get my measure, 

 

AvisosDepurado =
CALCULATE(COUNTROWS(Table);
FILTER(DIM_Reparac; (Table[Fecha_Aviso] >= [MINFecha_NPS] && DIM_Reparac[Fecha_Aviso] <= [MAXFecha_NPS])))
 
I have no idea how to proceed in that moment, need some help, 
 
Regards to all!
1 ACCEPTED SOLUTION

Hi @uvil 

You may refer to below measure.If it is not your case,please share some sample data and expected output which would be helpful to provide an accurate solution.You can also upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

How to Get Your Question Answered Quickly

Measure =
CALCULATE (
    COUNTROWS ( 'Table 2' ),
    FILTER (
        'Table 2',
        'Table 2'[Fecha_Aviso] >= MIN ( 'Table 1'[Fecha_NPS - Date] )
            && 'Table 2'[Fecha_Aviso] <= MAX ( 'Table 1'[Fecha_NPS - Date] )
    )
)

Regards,

Community Support Team _ Cherie Chen
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

3 REPLIES 3
uvil
Helper I
Helper I

In SQL, that query would be so good for me, but I don't know how to transform it in DAX

 

select * from Table
where YEAR(Fecha_Aviso) > 2018
and Fecha_Aviso>=(select MIN(Fecha_NPS) from Table)
and Fecha_Aviso<=(select MAX(Fecha_NPS) from Table)

 

I mean, now it's returning what a really need from the table, but I don't know how to translate it well to DAX,

 

Regards.,

I downloaded DAX Studio, and I worked with that platform, 

 

This query is giving me the values that I expected,

 

EVALUATE
FILTER (
    FILTER ( Table1, Table1[Fecha_Aviso] ),
    AND (
        CALCULATE ( SUM ( Table1[Fecha_Aviso] ) )
            >= MIN ( Table1[Fecha_NPS - Date] ),
        CALCULATE ( SUM ( Table1[Fecha_Aviso] ) )
            <= MAX ( Table1[Fecha_NPS - Date] )
    )
)
ORDER BY Table1[Fecha_NPS - Date]

 

But when I try to apply that formula to a measure in Power BI, it's giving me the next error:

 

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

And I don't know why the formula is working in DAX Studio, but in the other way is failing in PBI, 

 

Regards.,

Hi @uvil 

You may refer to below measure.If it is not your case,please share some sample data and expected output which would be helpful to provide an accurate solution.You can also upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

How to Get Your Question Answered Quickly

Measure =
CALCULATE (
    COUNTROWS ( 'Table 2' ),
    FILTER (
        'Table 2',
        'Table 2'[Fecha_Aviso] >= MIN ( 'Table 1'[Fecha_NPS - Date] )
            && 'Table 2'[Fecha_Aviso] <= MAX ( 'Table 1'[Fecha_NPS - Date] )
    )
)

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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