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
Anonymous
Not applicable

SQL to DAX

I want to count the rows where 'bedrag' is null

F.Bedrag
, M.Monster_NameDatum
, M.Monster_facturatiecode
, M.Monster_Naam
FROM DimMonster M
LEFT JOIN FactFacturering F on m.SK_MonsterKey = F.FK_MonsterKey
WHERE F.Bedrag is null

 

 

how do i count this in dax? Do i need to put a specific relationship in the the dax code?

8 REPLIES 8
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Have a try using this formula.

 

cal =
VAR a =
    VALUES ( M[SK_Monsterkey] )
RETURN
    CALCULATE (
        COUNTROWS ( F ),
        FILTER ( F, F[bedrag] = BLANK () && F[FK_MonsterKey] IN a )
    )
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thanks for your reply when i try your query it says 'Empty'
i actually want to count DimMonster so i changed the countrows to monster is this also correct?

Anonymous
Not applicable

Hello @Anonymous ,

 

You can try below formula:

Column = CALCULATE(COUNTROWS(FactFacturering),bedrag=BLANK()).

Also, create relationship between DimMonster and FactFacturering.

 

Thanks,

Bhavankit

Anonymous
Not applicable

countrows2.pngI want the 8792 also to show in the card but it doenst filter. I tried both suggestions above did not work

AnthonyTilley
Solution Sage
Solution Sage

This would depend on your report so we would need more detail as to what you are trying to achive.

 

that beeing said you can create a relationship between the two tables on your monsterkey filed and then create a simple measure for 

 

measure = count( FactFacturering[Bedrag])

 

alternativly if you do not want to create the relationship, then use a calulcalated colunm to look up the bedrag filed and add it to your Dimmonster table

 

Colunm = LOOKUPVALUE( FactFacturering[Bedrag],  DimMonster[SK_MonsterKey], FactFacturering[FK_MonsterKey])

Then use a count against this new field.

 

adding the relationship would always be the prefered approach.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




apologise misred your inital post the count i provided would only give you how many are not blank.

 

to count count null values use countblank( FactFacturering[Bedrag])





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

countrow.png


I want to count the empty column in gefactureerd. It already has an relationship

Does countblank(table[gefactureerd]) not work 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.