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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
smather
Helper III
Helper III

Measure Help - VAR Formula

I need to do a measure and I'm a lil stuck on the best way to go about it. 

 

Each person logs what they do in a day, and each person can have several entries per day. I need a VAR to assign 1 for each day, for each person, where a certain marker appears. The VAR will need to work when filtered to year, month and even down to day & person. It'd be looking for either a or c in the cat; this can show more than once in a single day for the same person, but it would still only need to to be one 1 and not several. 

 

The data looks a little like this: 

 

NameDate Time StartDate Time EndCatProject
Person 101/01/2022 8:0001/01/2022 10:00a123
Person 101/01/2022 10:0001/01/2022 12:00i123
Person 101/01/2022 12:0001/01/2022 12:30bN/A
Person 201/01/2022 07:0001/01/2022 10:00c321
Person 201/01/2022 10:0001/01/2022 17:00c321
Person 301/01/2022 11:0001/01/2022 14:00fN/A

 

Expected outcome: Person 1 and 2 would show 1 each for the 01/01 but Person 3 would not. 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @smather ;

In your data, here is "a." and "c." ;not "a", "c".

vyalanwumsft_0-1651818128372.png

so you should change the measure.

MyMeasure = 
CALCULATE(DISTINCTCOUNT('Table'[Full Name]), 'Table'[Cat] in {"a.", "c."})

The final output is shown below:

vyalanwumsft_1-1651818176961.pngvyalanwumsft_2-1651818182994.png


Best Regards,
Community Support Team _ Yalan Wu
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

8 REPLIES 8
v-yalanwu-msft
Community Support
Community Support

Hi, @smather ;

In your data, here is "a." and "c." ;not "a", "c".

vyalanwumsft_0-1651818128372.png

so you should change the measure.

MyMeasure = 
CALCULATE(DISTINCTCOUNT('Table'[Full Name]), 'Table'[Cat] in {"a.", "c."})

The final output is shown below:

vyalanwumsft_1-1651818176961.pngvyalanwumsft_2-1651818182994.png


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

PhilipTreacy
Super User
Super User

Hi @smather 

 

Download sample PBIX file

 

This measure works

 

Measure = 

VAR _x = CALCULATE(MINX('Table', [Date Time Start]), FILTER(ALL('Table'), 'Table'[Name] = MIN('Table'[Name])))
VAR _ac = MIN('Table'[Cat]) in {"a", "c"}

RETURN

SWITCH(

    TRUE(),

    _ac && (_x = MIN('Table'[Date Time Start])), 1,

    BLANK()
)

 

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi @PhilipTreacy 

 

I've tried your VAR, and JirkaZ's formula below, but I don't get anything. I just have a blank box. There are filters on the page (to remove breaks/lunch) but even if I remove them, nothing happens 😞 

 

Would it be benifical to share dummy data PBIX?  

Hi @smather 

 

Yes please, it's always beneficial to share the data/file you are working on so we are all working with the same data.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi @PhilipTreacy 

 

See link below. I've removed most identifying information, but the underlying data is what I'm essentially working with. 

 

PBIX Report 

 

Thank you, I appreciate this!

JirkaZ
Solution Specialist
Solution Specialist

Well the easiest would be something like this:

 

SUMX(VALUES(DimDate[Date]), 
   SUMX(VALUES(Person[Name]), IF(CONTAINSSTRING([Cat], "a") OR CONTAINSSTRING([Cat], "c"), 1, 0))
)

 

Just beware that with huge amount of rows it will get slow

Hi @JirkaZ 

 

thanks for replying!! I've tried your formula above, but as the Cat is a SWITCH column, it's not allowing me to reference it. And would this formula account for the fact that a or c could turn up more than once a day for the same engineer? 

JirkaZ
Solution Specialist
Solution Specialist

Yep - you're right.

 

This should work tho: 

 

MyMeasure = SUMX(VALUES('Calendar'[Date]),
CALCULATE(DISTINCTCOUNT(Logs[Person]), Logs[Cat] in {"a", "c"}
))

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.